stickyObjects.push(stickyObjForFile); // stickyObjForFile is obj, stickyObjects is array
what if are both objects, i use the same "push()"?
what if are both objects, i use the same
Page 1 of 13 Replies - 303 Views - Last Post: 30 January 2013 - 07:45 AM
Replies To: what if are both objects, i use the same
#2
Re: what if are both objects, i use the same
Posted 29 January 2013 - 03:09 AM
that depends on the methods provided by the stickyObjects object. if there is a push() method and it does what you want, then that will do.
as a rule of thumb, if stickyObjects is a plain object (i.e. if stickyObjects.toString() returns "[object Object]") there will be no (default) push() method.
as a rule of thumb, if stickyObjects is a plain object (i.e. if stickyObjects.toString() returns "[object Object]") there will be no (default) push() method.
#3
Re: what if are both objects, i use the same
Posted 30 January 2013 - 01:36 AM
i want to insert - push - a list of objects of same kind in another object... since the final i want to stringify to store in local storage or txt file i want this to be obj not array?
well what do to push one by one in a for loop objs to another obj(the latter acts like an array)...well?
well what do to push one by one in a for loop objs to another obj(the latter acts like an array)...well?
#4
Re: what if are both objects, i use the same
Posted 30 January 2013 - 07:45 AM
lse123, on 30 January 2013 - 09:36 AM, said:
i want to insert - push - a list of objects of same kind in another object... since the final i want to stringify to store in local storage or txt file i want this to be obj not array?
well, you could do some kind of "associative array"/hash map, which is just a couple of key-value pairs. though I don’t see any advantage over an Array (which is, btw., also an object). in contrast, by not using an Array you loose all the advantages an Array has (push, pop, iteration, loops, mutations)
lse123, on 30 January 2013 - 09:36 AM, said:
well what do to push one by one in a for loop objs to another obj(the latter acts like an array)...well?
if you want an Array-like object, why not using an Array? it’s not that you couldn’t stringify an Array for local storage …
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|