javascript - How do I add one single value to a JSON array? -
i kind of new world of interface, , found json amazing, simple , easy use. using js handle pain !, there no simple , direct way push value, check if exists, search, .... nothing !
and cannot add 1 single value json array, have :
loadedrecords = {}
i want :
loadedrecords.push('654654') loadedrecords.push('11') loadedrecords.push('3333')
why hard ???!!!
well .push
array function.
you can add array ur object if want:
loadedrecords = { recs: [] }; loadedrecords.recs.push('654654'); loadedrecords.recs.push('11'); loadedrecords.recs.push('3333');
which result in:
loadedrecords = { recs: ['654654', '11', '3333'] };
Comments
Post a Comment