对《JAVAScript设计模式》的拜读总结——第一章

这是一本对自身水平阶段进行考核的书。也是一本提升自己的书。五星推荐!!!!

第一章涉及内容不多。让我们一一消化。

一.prototype原型
prototype 属性使我们有能力向对象添加属性和方法。
只属于函数的属性。

二.将函数打包成对象类

   var checkObject=function(){};
    checkObject.prototype={
         checkName:function(){
            console.log('更改名字');
            
        }
    }

    var temp =new checkObject();
    temp.checkName();

在这里插入图片描述

链式调用写法:

   var checkObject=function(){};
    checkObject.prototype={
         checkName:function(){
            console.log('检测名字');
            return this
        },
        checkEmail:function(){
            console.log('检测邮件');
            return this
        }
    }

    var temp =new checkObject();
    temp.checkName().checkEmail();

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_36971710/article/details/83930720