الجديد في هذه الساعة
You Can also Pass the context `this` to the second function . However , in this case , you must call f2 as following: function f1(){ return f2.call(this) } -- function f2(){ return 123 } **UPDATE :** Passing context is very useful when you have Oriented Object Programming (`OOP`): I.E : function Person(bornYear){ this.born=bornYear ; this.age=Age.call(this,2014); } function Age(currentYear){ return currentYear-this.age; } If you note , `this.age` is not undefined because the context this has been passed from `Person` function to `Age` function
No comments:
Post a Comment