What will be the result of the code?

console.log(new Array(5).join('5'));
Explanation
new Array(5) creates new array without elements and with length = 5, example: var a = new Array(5); a.length // 5 join() method joins the elements of an array into a string, and returns the string and returns the string of elements separated by a specified separator. Example: a.join(5); // returns "5555" Empty 5 length array separated by '5' seperator;

It's really cool question!

2018 Jun 19, 11:36:45 AM

@iliana000, yeap! that's true, fixed!

2016 Jan 20, 5:37:40 PM

I tried in console: console.log(typeof new Array(5).join('5')); string

2016 Jan 15, 7:12:25 PM

WHY the correct answer is 5555 typeof Number, not String???

2016 Jan 15, 7:10:18 PM

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести