Setting the name property of an array does nothing for its serialized (JSON string) form. It does not put the record into an array. For this you need a.push('test') .
Objects are standard parts of Javascript (see, for example, MDC docs ). The usual way to create an object is {} , but new Object() also works.
So...
var a = []; a.push('test'); JSON.stringify(a); //"["test"]" a = {}; a.name = 'test'; JSON.stringify(a); //"{"name":"test"}"
source share