I accidentally discovered a behavior that has me scratching my head.
When I run console.log(1,027) the output is “1 23”. What?
What instruction am I actually giving it when I use the comma delimiter?
Using a comma in a console.log
statement allows you to print multiple values separated by a space. e.g.
console.log(1, “hello”, 98)
// 1 hello 98
console.log(1, 27)
// 1 27
You wrote: console.log(1, 027)
Have a look at this: Numbers and dates - JavaScript | MDN
In particular, note why 027
is being interpreted as an octal (base-8) number.