开发者

Rhino and Object.defineProperty

开发者 https://www.devze.com 2023-03-15 03:28 出处:网络
I have written the code below, and it complains the开发者_JAVA百科 the method \"defineProperty\" does not exist

I have written the code below, and it complains the开发者_JAVA百科 the method "defineProperty" does not exist

#! /usr/bin/rhino

version(170)

function PrivScop(priv) {
        this.access
        Object.defineProperty(this, "access", {
                get: function () { return priv },
                set: function () { priv = arguments[0] }
                }
        )
}
var secret = new PrivScop(1)

Is define property not implemented in version 1.7 or not at all. Am I doing something else wrong? Thanks in advance :-)


Object.defineProperty is defined in JS 1.8, which partially exists in Rhino 1.7R3, but is not enabled by default. I'm not sure if defineProperty itself exists in 1.7R3, but if it does you need to set the langage version to 180

0

精彩评论

暂无评论...
验证码 换一张
取 消