JavaScript基础
xxy阡陌
这个作者很懒,什么都没留下…
展开
-
《JavaScript设计模式与开发实践》——JavaScript中使用new关键字创建对象实例
举个例子: function Person( name ){ this.name = name; }; Person.prototype.getName = function(){ return this.name; }; var p1 = new Person(); console.log( Object.getPrototypeOf( a ) === Person.pro...原创 2018-03-14 10:40:49 · 531 阅读 · 0 评论 -
《JavaScript设计模式与开发实践》——JavaScript中的call和apply
几点基础知识: Function.prototype.call 和 Function.prototype.apply 方法用于改变内部函数 this 的指向 func.apply(thisArg[, argsArray]) 接受两个参数,第一个参数指定了 func 函数运行时的this,第二个参数是一个数组或者类数组对象 func.call(thisArg, arg1, arg2, ...) ...原创 2018-03-14 16:34:26 · 225 阅读 · 0 评论