how to add functionality inside js object

Solutions on MaxInterview for how to add functionality inside js object by the best coders in the world

showing results for - "how to add functionality inside js object"
Paulina
13 Sep 2016
1// four variables are created and assigned in a single go,
2// separated by commas
3var myObj = new Object(),
4    str = 'myString',
5    rand = Math.random(),
6    obj = new Object();
7
8myObj.type              = 'Dot syntax';
9myObj['date created']   = 'String with space';
10myObj[str]              = 'String value';
11myObj[rand]             = 'Random Number';
12myObj[obj]              = 'Object';
13myObj['']               = 'Even an empty string';
14
15console.log(myObj);
16
similar questions
queries leading to this page
how to add functionality inside js object