this,call,apply,bind

The prototype property allows you to add properties and methods to an object

Note:  Prototype is a global property, suitable for all Javascript objects.

function employee(name,jobtitle,born){
    this.name=name;
    this.jobtitle=jobtitle;
    this.born=born;
}
var fred=new employee("Fred Flintstone","Caveman",1970);
employee.prototype.salary=null;
fred.salary=20000;
document.write(fred.salary);

 

 

at this point the function are the following scenarios:

As new constructor is invoked;
used as a method object;
as a function of a direct call;
is call, apply, bind call;
arrow function in this;

 

new bindings

new bindings> Show Binding> implicit binding> default binding

 

this function arrow is binding and can not be modified apply bind by call 

var A = 20 is var obj = { 
    A: 40 , 
    foo :() => { 
        the console.log ( the this II.A) function FUNC () {
             the this II.A = 60 
            the console.log ( the this II.A) 
        } 
        func.prototype. A = 50
         return FUNC 
    } 
} var bar = obj.foo ()         // browser output: 20 is 
bar ()                       // browser output: 60 new new bar ()                   // browser output: 60


    
        
    


 

Guess you like

Origin www.cnblogs.com/webcyh/p/11291302.html