Let's make comprehension easy ...
undefined. On the other hand
null is actually an object reference even though you may believe at first otherwise. This is the reason
typeof null returns
There are different ways to create new objects:
The value of this, when used in a function, is the object that "owns" the function.
The value of this, when used in an object, is the object itself.
The this keyword in an object constructor does not have a value. It is only a substitute for the new object.
The value of this will become the new object when the constructor is used to create an object.
Objects created using an object literal, or with new Object(), inherit from a prototype called Object.prototype.
The standard way to create an object prototype is to use an object constructor function:
With a constructor function, you can use the new keyword to create new objects from the same prototype:
The constructor function is the prototype for Person objects.
Properties and methods can be added to the object at any time, but cannot be added directly to prototype. For example:
myFather.nationality = "English"; // is possible
Person.nationality = "Enginlish"; // is an error
Call and apply are pretty interchangeable. Just decide whether it’s easier to send in an array or a comma separated list of arguments.
I always remember which one is which by remembering that Call is for comma (separated list) and Apply is for Array.
Bind is a bit different. It returns a new function. Call and Apply execute the current function immediately.
Bind is great for a lot of things. We can use it to curry functions like in the above example. We can take a simple hello function and turn it into a helloJon or helloKelly. We can also use it for events like onClick where we don’t know when they’ll be fired but we know what context we want them to have.