WELCOME Abdennour : Software engineer

May 6, 2014

Stack Overflow is currently offline for maintenance

الجديد في هذه الساعة 

Stack Overflow is currently offline for maintenance

ِو كانت إجابتي الأخيرة هي هنا: 


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 ; 
    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