admin管理员组文章数量:1318156
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";
}
};
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";
}
};
Share
Improve this question
edited Jan 26, 2015 at 1:51
Bergi
666k161 gold badges1k silver badges1.5k bronze badges
asked May 16, 2011 at 3:22
AdamAdam
12.7k9 gold badges40 silver badges45 bronze badges
1 Answer
Reset to default 9Here's a patibility table for you.
http://kangax.github./es5-pat-table/
See the Getter in property initializer
and Setter in property initializer
rows.
According to the table:
- Firefox 4
- Safari 5
- Chrome 7-11
Other browsers (including IE9) are not given a Yes
or No
, so perhaps they're untested. I'm pretty sure IE9 supports it.
本文标签: Javascript get and set availability in browsersStack Overflow
版权声明:本文标题:Javascript get and set availability in browsers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742042338a2417605.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论