Rhino and Object.defineProperty
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
精彩评论