0

I guess this has something to do with binary numbers but I have not been able to find anything explaining why, most likely because I don't know what to search for. I have the following code. I pass in a number parameter of 0111 and inside the function body it logs the number 73. Im just trying to learn why. Linked resources with explanation would be nice. Thanks.

function whatTheHecksGoingOn(num) {
    console.log(num)
}

whatTheHecksGoingOn(0111);
Aaron
  • 2,364
  • 2
  • 31
  • 56

1 Answers1

0

Numericl literals beginning with 0 in JavaScript are interpreted as being in Octal notation. 0111 in Octal is equivalent to 73.

Dan
  • 10,282
  • 2
  • 37
  • 64