How to use a property of the object called a constructor?

Subject.
var o = {};
var c = 'constructor';

if (o[c] == undefined) o[c] = [];
o[c].push('val');

Code breaks with error: Uncaught TypeError: o[c].push is not a function
In principle, it is clear why. But I need a data structure with text keys (what is commonly called an associative array or dict) among which is the constructor - how to deal with it?
July 9th 19 at 13:11
2 answers
July 9th 19 at 13:13
Solution
1) do not use "constructor", "prototype", "hasOwnProperty"...
2) or
var o = Object.create(null);
key words: prototype pollution
The Power Of JavaScript. 68 ways to effectively use... page 175
Well at times to remember such infrequently used tricks) - antonetta.Collins commented on July 9th 19 at 13:16
But it was obvious
Damn. Spasibo huge! - everardo.Schulist commented on July 9th 19 at 13:19
July 9th 19 at 13:15
Do not use reserved names.
typeof o.constructor
"function"


As an option: add '_' before the key.
I would be happy, if reserved names are not used the words which I have put in the structure. The keys carry information and if I change them I'll lose her. Or do I have to do the structure not Emarsden: [Data partition] and N:{section: Maristela, data: Data section}. And how now to get access to the data section on his behalf? - antonetta.Collins commented on July 9th 19 at 13:18
the answer is more suitable for you.
But adding _ in front of the key, you can delete it when necessary, for information of the portable them - everardo.Schulist commented on July 9th 19 at 13:21

Find more questions by tags JavaScript