Learn Some new Advanced Techniques used for creating Functions
Safe Scope Constructors are created using functions which first checks to ensure that the this object is an instance of the correct type before execution is carried out.
In the demo below, a constructor myPhone has been used to add an if statement to ensure that the object this is an instance of myPhone
The Function Currying is an technique wherein a function is created with one or multiple arguments already set.
The idea is to use a closure to return a new function, and this new function sets some arguments which is passed when the function is called.
In the below demo, two functions multiply() and curryMultiply(), but the function curryMultiply() is same as Multiply() only difference being that it sets the first argument as 10.