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";
}
};
The get syntax binds an object property to a function that will be called when that property is looked up.
The concept of feature detection The idea behind feature detection is that you can run a test to determine whether a feature is supported in the current browser, and then conditionally run code to provide an acceptable experience both in browsers that do support the feature, and browsers that don't.
In the browser's toolbar, click on “Help"or the Settings icon. Click the menu option that begins “About” and you'll see what type and version of browser you are using.
Answer: To establish the actual name of the user's Web browser, you can use the navigator. appName and navigator. userAgent properties.
Here's a compatibility table for you.
http://kangax.github.com/es5-compat-table/
See the Getter in property initializer
and Setter in property initializer
rows.
According to the table:
Other browsers (including IE9) are not given a Yes
or No
, so perhaps they're untested. I'm pretty sure IE9 supports it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With