标签:object 创建 logs height test robot javascrip creat htm
// 原型对象: var Student = { name: ‘Robot‘, height: 1.2, run: function () { console.log(this.name + ‘ is running...‘); } }; function createStudent(name) { // 基于Student原型创建一个新对象: var s = Object.create(Student); // 初始化新对象: s.name = name; return s; } var xiaoming = createStudent(‘小明‘); xiaoming.run(); // 小明 is running... xiaoming.__proto__ === Student; // true
标签:object 创建 logs height test robot javascrip creat htm
原文地址:http://www.cnblogs.com/chenjf/p/6729205.html