标签:fine sharp har console his pre logs function get
function Person(name) { this.name = name; Object.defineProperty(this, ‘name‘, { get: function() { return name;}, set: function(newName) { if (name) { return;} return name = newName; } }); } var manx = new Person(‘manx‘); manx.name = ‘bob‘; console.log(manx.name); // manx; var smith = new Person(‘smith‘); console.log(smith.name); // smith
标签:fine sharp har console his pre logs function get
原文地址:http://www.cnblogs.com/ax-null/p/7112709.html