犀牛书笔记--客户端的js

ECMA5的存取器setter和getter定义私有属性

var set=(function namespace() {
    function Set(argument) {
        // body...
        this.a=a;
        this.b=b;
        .....
    }

    Set.prototype={
        foo1:function(){},
        foo2:function(){}
        ....
    };

    function f1(){}
    function f2(){}
    function f3(){}
    var nextId=1;
    return Set;
})


而对于一个大型的set模块---也就是说set的种类很多
    var collections;
    if(!collections) collections={};

    collections.set=(function namespace() {
        //定义各种类的set,诸如ListSet  LinkSet.....
        //LOCAL 变量  函数

        return {
            ArraySet:ArraySet,//这些属性的值都是构造函数~!
            ListSet:ListSet,
            ......
        }

    })()


1.Window对象是所有客户端js和API的接入点,客户端的js就运行在Window下
    以前使用过的alert,setInterval等等函数全是全局环境下的函数
    Window中最重要的属性是document
    var te=document.getElementById("te");
    if(te.firstChild==null){
        te.appendChild(document.createTextNode(new Date().toString()));
    }

2.每一个Element都有style和className属性,允许脚本指定文档的css样式

3.WEB文档:少量使用js,仅仅只是为了更好的用户体验,没有这些js应该也能正常进行工作
    Web应用:

posted @ 2015-11-09 22:36  Evans.wang  阅读(272)  评论(0编辑  收藏  举报