【问题标题】:Object.defineProperty for IEIE 的 Object.defineProperty
【发布时间】:2012-09-26 14:18:50
【问题描述】:
var o = {}; // Creates a new object

使用defineProperty 和数据属性描述符添加的对象属性示例

Object.defineProperty(o, "a", {value : 37,
                               writable : true,
                               enumerable : true,
                               configurable : true});

IE7-8如何实现?(属性可写、可枚举、可配置)

【问题讨论】:

标签: javascript


【解决方案1】:
if (!Object.defineProperty) {
        Object.defineProperty = function (obj, prop, descriptor) {
            if (arguments.length < 3) { // all arguments required
                throw new TypeError("Arguments not optional");
            }

            prop += ""; // convert prop to string
            ...     

【讨论】:

    猜你喜欢
    • 2011-04-19
    • 1970-01-01
    • 2013-06-20
    • 2022-12-13
    • 2023-03-24
    • 2014-02-06
    • 2021-10-18
    • 2017-08-07
    • 1970-01-01
    相关资源
    最近更新 更多