I'm making a dictionary of words, so there are 1,000,000+ words.
The problem comes when I need to store the word constructor. I know this is a reserved word in javascript, but I need to add it to the dictionary.
var dictionary = {}
console.log(dictionary ['word_1'])
//undefined, this is good
console.log(dictionary ['word_2'])
//undefined, this is good
console.log(dictionary ['constructor'])
//[Function: Object]
// this cause initialization code to break
How can I fix this? I could muck with the it like key=key+"_" but that seems bad. Is there anything else I can do?
['word_1', 'word_2', ...]or if you're gonna need some more information along with every word:[{word: 'word_1', anotherProperty: '...'}, ...].constructoris a reserved word, it is that objects inherit aconstructorproperty. (In a more general sense there is no problem creating object property names that are reserved words.).hasOwnProperty(), as already mentioned by t.niesse.