您的搜索结果

    Object

    概要

    如何生成一个对象的封装。

    语法

    new Object( [ value ] )

    参数

    任何值。

    描述

    Object*生成器以给定的值产生一个对象封装。如果给定值是nullundefined,它生成并返回一个空对象,否则,它将返回一个与给定值对应类型的对象。

    当在非生成器的上下文中调用时,Object*对象如何行事与上述(译注:即使用Object生成器时)一致。(译注:*此处特指前述语法代码中的Object,故不译)

    属性

    For properties available on Object instances, see Properties of Object instances.

    prototype
    允许对象类型的所有对象都附加属性。
    Properties inherited from Function:

    方法

    For methods available on Object instances, see Methods of Object instances.
    create Requires JavaScript 1.8.5
    Creates a new object with the specified prototype object and properties.
    defineProperty Requires JavaScript 1.8.5
    Adds the named property described by a given descriptor to an object.
    defineProperties Requires JavaScript 1.8.5
    Adds the named properties described by the given descriptors to an object.
    getOwnPropertyDescriptor Requires JavaScript 1.8.5
    Returns a property descriptor for a named property on an object.
    keys Requires JavaScript 1.8.5
    Returns an array containing the names of all of the given object's own enumerable properties.
    getOwnPropertyNames Requires JavaScript 1.8.5
    Returns an array containing the names of all of the given object's own enumerable and non-enumerable properties.
    getPrototypeOf Requires JavaScript 1.8.1
    Returns the prototype of the specified object.
    preventExtensions Requires JavaScript 1.8.5
    Prevents any extensions of an object.
    isExtensible Requires JavaScript 1.8.5
    Determine if extending of an object is allowed.
    seal Requires JavaScript 1.8.5
    Prevents other code from deleting properties of an object.
    isSealed Requires JavaScript 1.8.5
    Determine if an object is sealed.
    freeze Requires JavaScript 1.8.5
    Freezes an object: other code can't delete or change any properties.
    isFrozen Requires JavaScript 1.8.5
    Determine if an object was frozen.
    Methods inherited from Function:

    对象实例

    JavaScript语言的所有对象都是由Object衍生的对象;所有对象都继承了Object.prototype的方法和属性,尽管它们可能被覆盖。例如,其它的生成器原型覆盖了constructor属性并提供了其自己的toString方法。原型对象的更改会传播给所有的对象,除非这些属性和方法受到了原型链中那些进一步的变化的覆盖。

    属性

    方法

    例子

    例子:使用对象的给定undefinednull类型

    下面的例子将一个空的Object对象存到中o

    var o = new Object();
    
    var o = new Object(undefined);
    
    var o = new Object(null);
    

    例子:使用对象生成布尔对象

    下面的例子将布尔对象存到o中:

    // equivalent to o = new Boolean(true);
    var o = new Object(true);
    
    // equivalent to o = new Boolean(false);
    var o = new Object(Boolean());
    

    浏览器兼容性

    特性 Chrome框浏览器 火狐浏览器(Gecko) Internet Explorer Opera Safari (WebKit)
    基本支持 (Yes) (Yes) ? ? ?
    特性 安卓 移动火狐(Gecko) IE Phone Opera Mobile Safari Mobile
    基本支持 ? (Yes) ? ? (Yes)

     

    文档标签和贡献者

    对本页有贡献的人: ziyunfei, iwo, teoli
    最后编辑者: teoli,