日期:2014-05-16  浏览次数:20383 次

prototype第一行代码就把我搞懵了,请问javascript中的:号是做什么的,用作键值对吗?
代码如下:

var   Prototype   =   {
    Version:   '1.5.1.1 ',

    Browser:   {
        IE:           !!(window.attachEvent   &&   !window.opera),
        Opera:     !!window.opera,
        WebKit:   navigator.userAgent.indexOf( 'AppleWebKit/ ')   >   -1,
        Gecko:     navigator.userAgent.indexOf( 'Gecko ')   >   -1   &&   navigator.userAgent.indexOf( 'KHTML ')   ==   -1
    },

    BrowserFeatures:   {
        XPath:   !!document.evaluate,
        ElementExtensions:   !!window.HTMLElement,
        SpecificElementExtensions:
            (document.createElement( 'div ').__proto__   !==
              document.createElement( 'form ').__proto__)
    },

    ScriptFragment:   ' <script[^> ]*> ([\\S\\s]*?) <\/script> ',
    JSONFilter:   /^\/\*-secure-([\s\S]*)\*\/\s*$/,

    emptyFunction:   function()   {   },
    K:   function(x)   {   return   x   }
}

------解决方案--------------------
var 对象= {
属性名: 属性值,
方法名: 方法
}

调用时:对象.属性; 或者: 对象.方法

另一种

var 对象.prototype = {
属性名: 属性值,
方法名: 方法
}

var 实例对象名 = new 对象();
实例对象名.属性名; 实例对象名.方法名
------解决方案--------------------
JSON是一种JS的基础数据结构
是一种比XML更快捷更高效的数据模型,GOOGLE MAP就是用它做的数据交换
具体看这里
http://www.javaeye.com/topic/71343
http://hi.baidu.com/hibydu/blog/item/ef9b17fab7c1a51ca8d3119e.html

而用function可以定义的是类,两种差不多,但本质上稍微有点区别