parse string in javascript code example
Example 1: string to array javascript
const str = 'Hello!';
console.log(Array.from(str));
Example 2: javascript parse to string
var bar = foo.toString();
Example 3: javascript split
var arr = foo.split('');
console.log(arr);
Example 4: split() javascript
let countWords = function(sentence){
return sentence.split(' ').length;
}
console.log(countWords('Type any sentence here'));
Example 5: parse string javascript
parseFloat("16.5");
parseInt("34.6");
JSON.parse('{ "name":"John", "age":30, "city":"New York"}');