0

Here it is described how to check if innerHTML property is configurable and enumerable using Firebug/FF Web Console. How can I check the same for charCodeAt function? Object.getOwnPropertyDescriptor(HTMLElement.prototype,"charCodeAt") return undefined.

Community
  • 1
  • 1
tic
  • 4,009
  • 15
  • 45
  • 86
  • It says that it doesn't work in Firebug there. Make sure you are using the FF web console and not firebug – PitaJ Aug 08 '12 at 22:09

2 Answers2

4

The .charCodeAt() method belongs to Strings, not to HTMLElement:

Object.getOwnPropertyDescriptor(String.prototype,"charCodeAt")
nnnnnn
  • 147,572
  • 30
  • 200
  • 241
  • It's directly on `String`, instead of `String.prototype`. –  Aug 08 '12 at 22:09
  • @amnotiam pretty sure it's in the prototype :P You are thinking `fromCharCode` – Esailija Aug 08 '12 at 22:10
  • @amnotiam - Are you sure? When I [try it out](http://jsfiddle.net/nnnnnn/7KPzq/) with `String.prototype` it works but `String` doesn't. (Testing in Chrome.) – nnnnnn Aug 08 '12 at 22:11
  • 1
    @Esailija, nnnnnn: You're right. Though in Firefox it's also on `String`. +1 –  Aug 08 '12 at 22:12
  • 1
    Yeah, that's nonstandard. Firefox also adds Array.forEach and so on. – Esailija Aug 08 '12 at 22:12
2

This is because charCodeAt is not a method of HTMLElement, it's a method in the String-Object (or rather its prototype)

Object.getOwnPropertyDescriptor(String.prototype,"charCodeAt")
GNi33
  • 4,459
  • 2
  • 31
  • 44
  • @amnotiam it lies in the prototype, checking only on `String` returns undefined in Chrome for example – GNi33 Aug 08 '12 at 22:11