- 필수 기능
- 시작하기
- Glossary
- 표준 속성
- Guides
- Agent
- 통합
- 개방형텔레메트리
- 개발자
- Administrator's Guide
- API
- Datadog Mobile App
- CoScreen
- Cloudcraft
- 앱 내
- 서비스 관리
- 인프라스트럭처
- 애플리케이션 성능
- APM
- Continuous Profiler
- 스팬 시각화
- 데이터 스트림 모니터링
- 데이터 작업 모니터링
- 디지털 경험
- 소프트웨어 제공
- 보안
- AI Observability
- 로그 관리
- 관리
ID: typescript-code-style/radix
Language: TypeScript
Severity: Notice
Category: Best Practices
When utilizing the parseInt()
function, many often skip the second parameter (the radix), allowing the function to deduce the number type based on the initial argument. By default, parseInt()
can recognize both decimal and hexadecimal numbers, the latter through the 0x
prefix. However, before ECMAScript 5, the function also mistakenly recognized octal numbers, leading to issues as many developers presumed a starting 0
would be disregarded.
parseInt();
parseInt();
parseInt("10");
parseInt("10",);
parseInt((0, "10"));
parseInt((0, "10"),);
parseInt("10", null);
parseInt("10", undefined);
parseInt("10", true);
parseInt("10", "foo");
parseInt("10", "123");
parseInt("10", 1);
parseInt("10", 37);
parseInt("10", 10.5);
Number.parseInt();
Number.parseInt();
Number.parseInt("10");
Number.parseInt("10", 1);
Number.parseInt("10", 37);
Number.parseInt("10", 10.5);
parseInt?.("10");
Number.parseInt?.("10");
Number?.parseInt("10");
(Number?.parseInt)("10");
parseInt("10", 10);
parseInt("10", 2);
parseInt("10", 36);
parseInt("10", 0x10);
parseInt("10", 1.6e1);
parseInt("10", 10.0);
parseInt("10", foo);
Number.parseInt("10", foo);
parseInt("10", 10);
parseInt("10", 8);
parseInt("10", foo);
parseInt
Number.foo();
Number[parseInt]();
class C { #parseInt; foo() { Number.#parseInt(); } }
class C { #parseInt; foo() { Number.#parseInt(foo); } }
class C { #parseInt; foo() { Number.#parseInt(foo, 'bar'); } }
class C { #parseInt; foo() { Number.#parseInt(foo, 10); } }
// shadowed not supported
// Ignores if it's shadowed or disabled.
// var parseInt; parseInt();
// var parseInt; parseInt(foo);
// var parseInt; parseInt(foo, 10);
// var Number; Number.parseInt();
// var Number; Number.parseInt(foo);
// var Number; Number.parseInt(foo, 10);
// /* globals parseInt:off */ parseInt(foo);
// Number.parseInt(foo, 10);