I have to find an equivalent code to :
Object.defineProperty(object, sProperty, vValue);
because i'm working with an old js interpreter which doesn't support ECMA Javascript5, so i'm trying to switch to this code :
if(vValue.get)
object["get "+ sProperty] = vValue.get;
if(vValue.set)
object["set " + sProperty] = vValue.set;
Assuming
vValue
is of the formvalue: x
, thenIf
vValue
is a property descriptor includingget
andset
, then you could experiment with using__defineGetter__
and__defineSetter__
if they are available in your environment:For a more full-featured implementation, see the polyfill at https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties#Polyfill.