一.for in 1.使用 for in 循环遍历对象的属性时,原型链上的所有属性都将被访问: Object.prototype.say="cgl"; // 修改Object.prototype var person ={ age: 18 }; for (var key in person) { console.log(key, person[key]);//这里用person.key得不到对象key的值,用person[key] 或者 eval("person.&quo
语法:父对象.prototype.isPrototypeOf(子对象) 代码栗子: function Student(){ this.name = "小马扎"; ; } var sky = new Student(); var img = new Image(); console.log(Student.prototype.isPrototypeOf(sky)); // true console.log(Student.prototype.isPrototypeOf(img)); //
自调用函数 var name = 'world!'; // console.log(typeof name) (function () { console.log(this.name, name, typeof name, typeof name === undefined) if(typeof name === undefined){ var name = 'a!' console.log('hello ' + name) } else{ var name = 'b!' console.lo