JSFiddle - React, Tailwind, and code Playground
by xxxwww
JavaScript
var int = 100101,
str = '100101',
a = [];
// 1 string loop
for(var i = 0; i < str.length; i++){
a.push(str[i]);
}
console.log(a);
// 2 int to string loop
str = int.toString();
for(var i = 0; i < str.length; i++){
a.push(str[i]);
}
console.log(a);
// 3 string split
a = str.split('');
console.log(a);
// 4 int to string split
a = int.toString().split('');
console.log(a);