+ 1

Why does this code give no output?

let a = [5, 2]; (() => { console.log(a[0]); });

16th Mar 2018, 8:16 PM
Briaה‎
1 Odpowiedź
+ 4
To call (execute) the main function, you must put a pair of parenthesis just before the last semi-colon, else you just define an anonymous function that you never can call (because definition of anonymous function is to not have a reference name): Why does this code give no output? let a = [5, 2]; (() => { console.log(a[0]); })(); Anyway, In a browser, you must open the developer tools panel to see the output logged in console. In the sololearn code playground, this will be outputed in an overlay, at bottom of the web output.
16th Mar 2018, 10:01 PM
visph
visph - avatar