If I have some values and I want to store it as an object. So finally I need to call JSON.stringify()
(because I am trying to store it in chrome extension)
var id = '1';
var name = 'Mali Bakery'
var url = 'http://example.com/'
So I thought the best thing would be sorting it like:
var items = {
id : {
'name': name,
'url': url
}
}
But I couldn't figure out how to put the variables inside the object template.
I tried using
item = {}
item[id] = id
item[id].name = name
// etc
items.push(item);
// and also, this approach too
items.id = id
But no success.