{ 'notes[]': [ 'book', 'copy', 'pencil', 'eraser' ] }
I just want to parse these sets. Please, anyone suggest me some best approach
{ 'notes[]': [ 'book', 'copy', 'pencil', 'eraser' ] }
I just want to parse these sets. Please, anyone suggest me some best approach
Since you are using an invalid identifier as your key (notes[]
), you will need to use bracket syntax to access:
var data = { 'notes[]': [ 'book', 'copy', 'pencil', 'eraser' ] };
console.log(data['notes[]']);
Probably would be better to name the key notes
instead of notes[]
. Then you can access with dot notation: data.notes
Maybe you want like as below code.
var res = { 'notes': [ 'book', 'copy', 'pencil', 'eraser' ] };
console.log(res.notes[0]); //=> book
console.log(res.notes[1]); //=> copy
console.log(res.notes[2]); //=> pencil
console.log(res.notes[3]); //=> eraser