我正在阅读Addy Osmani的书籍JavaScript设计模式,为什么当它不起作用时他会使用这样的配置?
var defineProp = function ( obj, key, value) {
config.value = value;
Object.defineProperty(obj, key, config);
}
var man = Object.create(null);
defineProp( man, 'car', 'Delorean');
defineProp( man, 'dob', '1981');
defineProp( man, 'beard', false);
// As we will see a little later in the book, these methods can even be used for inheritance, as follows:
var driver = Object.create(man);
defineProp(driver, 'topSpeed', '100mph');
driver.topSpeed // 100mph