JavaScript push to array -


how push new values following array?

json = {"cool":"34.33","alsocool":"45454"} 

i tried json.push("coolness":"34.33");, didn't work.

it's not array.

var json = {"cool":"34.33","alsocool":"45454"}; json.coolness = 34.33; 

or

var json = {"cool":"34.33","alsocool":"45454"}; json['coolness'] = 34.33; 

you array, different syntax (and not want)

var json = [{"cool":"34.33"},{"alsocool":"45454"}]; json.push({"coolness":"34.33"}); 

note variable name highly misleading, there no json here. name else.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -