js给对象添加属性

obj.prototype = shuxing;

shuxing['属性']=值;

function Person(){};
var person = new Person();
person.name = 'yy';
person.gender = 'girl';
console.log(person.name+','+person.gender);//yy,girl
delete person.name;//删除属性
console.log(person.name);//undefined
//            变式
function Person(){};
var person = new Person();
person['name'] = 'yy';
person['gender'] = 'girl';
console.log(person.name+','+person.gender);//yy,girl
delete person.name;//删除属性
console.log(person.name);//undefined     

 

posted on 2018-02-06 11:35  o_0的园子  阅读(25581)  评论(0编辑  收藏  举报