i new in javascript + nodejs
i want display array in javascript from nodejs..
this result from node.js (i use JSON.stringify())
[{"id":"i01","name":"jack","phone":"123123"},{"id":"i02","name":"john","phone":"123123"},{"id":"i03","name":"jane","phone":"123123"}]
i want display that array like this
id | name | phone
---+-------+----------i01 | jack |123123
i02 | john |123123
i03 | jane |123123
how can i achive what i want ?
thanks
var mypost = [{"id":"i01","name":"jack","phone":"123123"},{"id":"i02","name":"john","phone":"123123"},{"id":"i03","name":"jane","phone":"123123"}]
var mm = mypost[0].id // return i01
var mm1 = mypost[1].name // return john
var mm2 = mypost[2].phone // return 123123(phone3)
take a look here to check the way to iterate an array: For each in a array. How to do that in javascript?
Hope it helps
Refer below example and apply. Try it once...
var obj = { x: '1', a: '2', b: '3'};
var items = Object.keys(obj);
items.forEach(function(item) {
console.log(item + '=' + obj[item]);
});
its't that much difficult to solve, understand the array concept and iterate concept and apply.
Refer below link for reference of node.js document