Using new object to create objects

Time:2021-3-11

Var obj = new object(); / / an empty object is created
obj.uname = ‘zhangsanfeng’;
obj.name =18; / / the literal way to create an object is different. Here you need to use = assignment to add properties and methods
obj.sex =’Nan’; / / attributes and methods end with
obj.sayHi = function() {

console.log(‘hi’);
}

console.log(obj.uname);  
console.log(obj[‘age’]);