8

According to http://www.w3.org/TR/IndexedDB/#widl-IDBCursor-continue, the IDBCursor object has methods named "continue" and "delete". Aren't those reserved keywords? Why would they use these names in the specs?

My javascript compiler keeps warning me about the reserved keyword and its really annoying.

hugomg
  • 68,213
  • 24
  • 160
  • 246
Chan Le
  • 2,184
  • 3
  • 23
  • 33
  • 2
    It's perfectly valid to use a reserved word as a property name (and hence any warning your compiler gives is bogus) per ES5 (though not per ES3), and all existing IndexedDB implementations are in browsers with ES5 support. – gsnedders Aug 29 '11 at 20:32
  • Google's closure compiler does this as well. – buley Nov 29 '11 at 02:25
  • Regardless of it's validity, it's confusing – earcam Sep 13 '12 at 17:51

2 Answers2

14

If you just want to "shut the compiler up" you can use string based property access instead:

obj['continue']

is the same as

obj.continue
hugomg
  • 68,213
  • 24
  • 160
  • 246
2

The presence of .continue() will make IE8 bark with "SCRIPT1010: Expected identifier" even if that part of the code is never run. So it is probably a good thing that your compiler warns you.

missingnos solution solved this problem.

sorenbs
  • 749
  • 4
  • 7
  • Also other tools (minifiers) have this issue. Using objectStore("myStore")['delete'](args) and cursor['continue']() solves the issue fine, as per missingno. Quite ugly actually this is actually in the official Mozilla documentation/example, with no hint on that..?! https://developer.mozilla.org/en-US/docs/IndexedDB – Chris Dec 17 '13 at 10:47