每日点点滴滴!!!

    技术2022-07-10  134

    续前节js

    继承:继承某个对象的原型 【在原型空间上加东西,继承者的空间同理也加东西】 【如果既要继承别人的原型,又要自身加东西不影响别人,中间加个过度】

    Father.prototype.Lastname = 'nimeng'; function inherit(Target,Oringin){ var F = function () {}; return function(Target,Oringin){ F.prototype = Oringin.prototype; Target.prototype = new f(); } // function Son(){ // }; // function Father(){ // }; // inherit(Son,Father); 命名空间:管理变量 防止污染全局,适用于模板化开发【命名空间,闭包{私有化}】实现链式调用模式【obj.eat().smoke().drink().perm().sleep();】属性的表达方式:1.bgj.prop 2.obj[‘prop’] -遍历:obj.name-------obj[‘name’]【for里面一定写[ ]】

    对象的枚举: 1. for in 2. hasOwnproperty 3. in 4. instanceof A instanceof B:

    A对象 是不是 B构造函数构造出来的看A对象的原链上 有没有B的原型 var nimeng = { name:'xiaoliu', age:19, sex:"male", height:160, weight:75, } var prop; for(prop in fenda){ if(fenda.hasOwnproperty(prop)){ console.log(nimeng[prop]); } }

    Typeof返回的结果可能有: 1. 字符串 2. function 3. number 4. object 5. undefined 6. 布尔值 (后期小编会写关于jQuery的返回结果,你意想不到的结果)

    This: 1.函数与编译过程 ------ window 2.全局作用域里this ------ window 3.call/apply可以改变函数运行时this的指向 4.obj.func() func()里面的this指向obj

    var nimeng = { smoke:function(){ console.log('peipei'); return this; }, drink:function(){ console.log('nice!'); return this; }, perm:function(){ console.log('cool'); return this; }, sleep:function(){ console.log('goodnight!'); return this; } } nimeng.smoke().drink().perm().sleep();

    this简单描述: 1.谁调用this指向谁 2.没有调用就是指向全局或者undefined

    Arguments(一般是指参数): 1.Arguments.callee : 指向函数自身引用【用于引用该函数的函数体内当前正在执行的函数。这在函数的名称是未知时很有用,例如在没有名称的函数表达式 (也称为“匿名函数”)内。】 var num = (function(n){ if(n == 1){ return 1; } return n*arguments.callee(n-1); }(20)) 2.Func().caller

    var num = (function(n){ if(n == 1){ return 1; } return n*arguments.callee(n-1); }(20))
    Processed: 0.008, SQL: 9