Program to use JavaScript Array.from() method
let a = 'JavaScript';
let b = Array.from(a);
console.log(b);
Output
[
'J', 'a', 'v', 'a',
'S', 'c', 'r', 'i',
'p', 't'
]
Steps Description
- Declare two variable
a
andb
- Initialize two variable
a
andb
with value of stringa = 'JavaScript'
andb = Array.from(a)
Array.from()
method creates new array from array element- The value of
b
variable is displayed with the help of console.log inbuilt function