Which browsers do not support the get and set methods for object prototypes? I believe this is a feature of ES5, an I know it works in Chrome, but I am wondering if it is safe to use for ajax apps. Here’s an example:
var foo = function () {};
foo.prototype = {
get name () {
return this._name;
},
set name (n) {
this._name = n || "bar";
}
};
Here’s a compatibility table for you.
http://kangax.github.com/es5-compat-table/
See the
Getter in property initializerandSetter in property initializerrows.According to the table:
Other browsers (including IE9) are not given a
YesorNo, so perhaps they’re untested. I’m pretty sure IE9 supports it.