can declare a function inside a function in javascript. How:
function my(){
function check(){
return true;
}
console.log( check() ? "yes" : "no");
}
my();
However, this may not be the fastest, because every time I get called, the check must be re-announced. But an ad check outside my facility could pollute the global area.
If mine was a My constructor , validation can be added to its prototype, but, unfortunately, this does not work with normal functions.
What is a convenient way to solve this problem?
source
share