Can I add Jquery Object to the blank object as key. For example:-
var obj = {};//blank object
var myId = $("#myId");//jQuery Object
var myId2 = $("#myId2");//another jQuery Object
obj[myId] = "Trying to add myId as a key";
obj[myId2] = "Trying to add myId2 as a key";
But the output of the obj contains only one key. Is the above thing is possible in JS or not?
Thanks in advance.
$('#myId').toString()produces"[object Object]", and$('#myId2').toString()also produces"[object Object]". How do you expect to differentiate between them? Just like runningobj = {}; obj.foo = 1; obj.foo = 2;and asking why you only get one key.obj = {'#myId': $('#myId'), '#myId2': $('#myId2')};