如何检查charCodeAt()是否可配置

时间:2012-08-08 22:01:27

标签: javascript firebug enumerable configurable

Here描述了如何使用Firebug / FF Web控制台检查innerHTML属性是否可配置和可枚举。 如何查看charCodeAt函数的相同内容? Object.getOwnPropertyDescriptor(HTMLElement.prototype,"charCodeAt") 返回undefined

2 个答案:

答案 0 :(得分:4)

.charCodeAt() method属于Strings,而不属于HTMLElement

Object.getOwnPropertyDescriptor(String.prototype,"charCodeAt")

答案 1 :(得分:2)

这是因为charCodeAt不是HTMLElement的方法,它是String - 对象(或者更确切地说是原型)中的方法

Object.getOwnPropertyDescriptor(String.prototype,"charCodeAt")