I dont understand why this happened


I understand objects pretty well(I might go through it again to get the hang of it), but something strange happened...


var robot = new Object();
robot.id = 0002020110304;

var myArray = [12, false, "James", robot];

When I ran this code, I got the output "272666820". I know the last part of the object gets printed to the console, but why did a different number get printed than what I had for the .id of the robot object? Is ".id" a function?


You get that because of the extra leading zeros here:

Hope this helps! :smile:


So it's like all real numbers: you can't have a zero in front of it?


In JS, numbers that begin with 0 and are followed by octal digits are octal and not decimal numbers.