Q:

parse string javascript


 var a = parseInt("10");

 
3
//split into array of strings.
var str = "Well, how, are , we , doing, today";
var res = str.split(",");
29
var bar = foo.toString();
1
var myString = 'no,u';
var MyArray = myString.split(',');//splits the text up in chunks
11
//You can call .toString() on every defined variable.

var x1 = Boolean(0); x1.toString(); // --> false
var x2 = Boolean(1); x2.toString(); // --> true
var x3 = new Date("2020/03/13"); x3.toString(); // --> Fri Mar 13 2020 00:00:00 GMT+0100
var x4 = "12345"; x4.toString(); // --> 12345
var x5 = 12345; x5.toString(); // --> 12345
3
var names = 'Harry ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ';

console.log(names);

var re = /\s*(?:;|$)\s*/;
var nameList = names.split(re);

console.log(nameList);
4
parseFloat("16.5"); // 16.5
parseInt("34.6"); // 34
JSON.parse('{ "name":"John", "age":30, "city":"New York"}'); // {name: "John", age: 30, city: "New York"}
0

New to Communities?

Join the community