javascript apply, call and constuctor

Let’s first create a simple function that we will be using through the rest of this post. This function will just return an array with the current value ofthis and the two supplied arguments. <script type=“text/javascript”> function makeArray(arg1, arg2){     return [ this, arg1, arg2 ]; } </script> Most common way, unfortunately, global function calls When we are learning JavaScript we learn how to define…

javascrip closure

First, a very very good article explaining CLOSURE Second, I like this answer in Stackoverflow: A function in JavaScript is not just a reference to a set of instructions (as in C language) but also includes a hidden data structure which is composed of references to all nonlocal variables it uses (captured variables). Such two-piece…

javascrip callback

How Callback Functions Work? Because functions are first-class objects in JavaScript, we can treat functions like objects, so we can pass functions around like variables and return them in functions and use them in other functions. When we pass a callback function as an argument to another function, we are only passing the function definition….