console.log()
과 다르게 작동합니다.콘솔에 숫자를 쓸 때 이상한 행동이 숫자에 대해
아래의 발견은 흥미 롭습니다. 설명이 뭐야?
console.log(1)
-1
console.log(01)
-1
console.log(12)
- 12
console.log(012)
-10
console.log(0123)
-83
console.log(123)
-123
편집
Integers can be expressed in decimal (base 10), hexadecimal (base 16), and octal (base 8).
Decimal integer literal consists of a sequence of digits without a leading 0 (zero).
Leading 0 (zero) on an integer literal indicates it is in octal. Octal integers can include only the digits 0-7.
Leading 0x (or 0X) indicates hexadecimal. Hexadecimal integers can include digits (0-9) and the letters a-f and A-F.
Octal integer literals are deprecated and have been removed from the ECMA-262, Edition 3 standard (in strict mode). JavaScript 1.5 still supports them for backward compatibility.
'console.log (012); // 10' 이런 식으로 이상하게 디버깅 할 때 코드를 줄이면 관련되지 않을 수있는 메서드가 제거됩니다. –
@KevinB - 네 말이 맞아. 해야만 했어. 그 기능이 이상한 행동이라고 생각했습니다. 되지 않도록. – Krishna