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
Post a Comment