rubixibuc
rubixibuc

Reputation: 7397

Rhino and Object.defineProperty

I have written the code below, and it complains the 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 :-)

Upvotes: 0

Views: 673

Answers (1)

user578895
user578895

Reputation:

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

Upvotes: 3

Related Questions