Interview summary - function call

this refers to the object that calls the function

① as a function call to
call the return function----the corresponding parameters are passed when the function is created and called
console.log(one(1,2));
function one (a,b){
    var abcOne;
    abcOne = a + b;
    return(abcOne);
};
②As an object method call --> the value of this becomes the object itself
var object ={
    a:1,
    b:2,
    c:function(){
        return this. a + this.b;
    }  
}
console.log(JSON.stringify(this)) ③Constructor
call
function one (a,b){
    this.a = a;
    this.b = b;
}
var x = new one( "nn","mm")
console.log(xa)


added to the page:
document.getElementById("demo").innerHTML = one(1,2);

data type:
Simple data includes undefined, null, boolean, number and string
. There is only one complex data type, that is, objects, while arrays are special objects.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326474344&siteId=291194637