Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
console.log(Array.from('hello')); // ['h','e','l','l','o'] console.log(Array.from(new Set([1, 2, 2, 3]))); // [1,2,3] console.log(Array.from({length: 5}, (_, i) => i)); // [0,1,2,3,4] console.log(Array.from({length: 5}, (_, i) => i + 1)); // [1,2,3,4,5] console.log(Array.of(1, 2, 3)); // [1,2,3] console.log(Array.of(7)); // [7] console.log(Array(7)); // [,,,,,,] sparse! console.log(Array.from(new Map([['a', 1], ['b', 2]]))); // [['a',1],['b',2]]
Result
Open