View Single Post
  #1 (permalink)  
Old October 6th, 2015, 02:55 AM
dysonlu dysonlu is offline
Registered User
Points: 58, Level: 1
Points: 58, Level: 1 Points: 58, Level: 1 Points: 58, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2015
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem With Constructors

In chapter 6, the author explains that the constructor

function Person(name, age, job){
this.name = name;
this.age = age;
this.job = job;
this.sayName = function(){
alert(this.name);
};
}

is logically equivalent to this:

function Person(name, age, job){
this.name = name;
this.age = age;
this.job = job;
this.sayName = new Function("alert(this.name)"); //logical equivalent
}

But he very briefly mentions that "creating a function in this manner is different with regard to scope chains and identifier resolution".

I do not understand what he meant by that. Can anyone explain?

Thanks much!
Dyson
Reply With Quote