当前位置:网站首页>JS -- reference type

JS -- reference type

2022-06-11 05:47:00 Lao Liu selling vegetables at the corner of the street

Object is an instance of a specific reference type

var person=new Object();====>Object It's a constructor

The two methods :

1

var person =new Object();

person.name="";

person.age=;

2

var person={name:;age:;}

 

 

function displayInfo(args) {
    var output="";
    if(typeof args.name=="string"){
        output+="name:"+args.name+"\n";
    }
    if(typeof args.age=="number"){
        output+="Age:"+args.age+"\n";
    }
    console.log(output);
}

displayInfo({
    name:"solin",
    age:22
});

name: solin

age:22

 

原网站

版权声明
本文为[Lao Liu selling vegetables at the corner of the street]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020533538277.html