Where my code went wrong?


var james = {
job: "programmer",
married: false,
sayJob: function() {
// complete this method
console.log('Hi, I work as a ' + this.job);

// james' first job

// change james' job to "super programmer" here
this.job: 'super programmer' ;

// james' second job

Do I can use james and this arbitrary in place of each other or there is some specification regarding it


There is a specification which relates to object context.


In the above, sayJob() is a method of the james object literal. All methods of this object have a common variable that specifies their execution context... this, the internal pointer to the reference object, james.

The operative word here is internal. In outer scope, where james exists, this is not accessible. To access the job property directly we have to go through public channels and use the formal, or property specific identifier,


Make sense?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.