var person = {}; Object.defineProperties(person,{ title : {value : 'fe'}, crop : {value : 'BABA'}, salary : {value : 5000}, luck : { get : function () { return Math.random() > 0.5 ? 'good' : 'bad'; } }, promote : { set : function(level) { this.salary *= level; } } }); // var obj = Object.getOwnPropertyDescriptor(person,'luck'); // console.log(obj); // console.log(person.salary); person.promote = 2; console.log(person.salary)
换个浏览器试试。。老师生成的cvs是canvas的画笔,无法设置canvas(画布的大小)~!,设置canvas的大小是需要对canvas(画布)对象,而不是canvas的context(画笔),...
salary的writable默认为false 所以无法改动
salary : {value : 5000,writable: true},显示指定下属性writable,默认是false
结果为什么还是5000