parse array javascript code example
Example 1: parseint array javascript
var arr = ['1','2','3'];
arr = arr.map(x => parseInt(x));
console.log(arr);
//Array(3) [ 1, 2, 3 ]
Example 2: javascript parse json
var jsonPerson = '{"first_name":"billy", "age":23}';
var personObject = JSON.parse(jsonPerson); //parse json string into JS object
Example 3: javascript parse json
const json = '{ "fruit": "pineapple", "fingers": 10 }';
const obj = JSON.parse(json);
console.log(obj.fruit, obj.fingers);
Example 4: js string to object
JSON.parse()