Avoid using octal literals to prevent unexpected behavior

이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

Metadata

ID: javascript-best-practices/no-octal

Language: JavaScript

Severity: Error

Category: Best Practices

CWE: 682

Description

In JavaScript, numbers that start with a leading zero (0) are considered octal (base-8) literals. However, octal literals can lead to unintended and unexpected behavior, especially for developers who are not familiar with this notation or when used accidentally.

Non-Compliant Code Examples

var a = 01234;
a = 1 + 01234;
00;
08;
09.1;
09e1;
09.1e1;
018;
019.1;
019e1;
019.1e1;

Compliant Code Examples

var a = 'hello world';
0x1234
0X5;
a = 0;
0.1
0.5e1
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis

PREVIEWING: mervebolat/span-id-preprocessing