严格模式 所谓严格模式,从字面上就很好理解,即更严格的模式 在这种模式下执行,浏览器会对JS的要求更苛刻. 举例: function m1(){ max = 100; } m1(); alert(max); //由于max没有var声明,因此max会变成全局变量 但是在严格模式下: function m1(){ "use strict"; ; } m1(); alert(max); Uncaught ReferenceError: max is not define
Object.defineproperty语法 var o = {}; // 创建一个新对象 // Example of an object property added with defineProperty with a data property descriptor Object.defineProperty(o, "a", {value : 37, writable : true, enumerable : true, configurable : true}); // 对象
多态的好处: A:提高了代码的维护性(继承保证) B:提高了代码的扩展性(由多态保证) 猫狗案例代码 class Animal { public void eat(){ System.out.println("eat"); } public void sleep(){ System.out.println("sleep"); } } class Dog extends Animal { public void eat(){ System.out.println(&q