W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더). - Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외) - Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체) - Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속) 각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8.6 KiB
id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
| id | title | category | status | verification_status | canonical_id | aliases | duplicate_of | source_trust_level | confidence_score | created_at | updated_at | review_reason | merge_history | tags | raw_sources | applied_in | github_commit | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| javascript-number-methods | JavaScript Number Methods | Frontend | draft | conceptual |
|
B | 0.89 | 2026-06-23 | 2026-06-23 |
|
|
JavaScript Number Methods
🎯 한 줄 통찰 (One-line insight)
Basic number methods (toString, toExponential, toFixed, toPrecision, valueOf) work on any number, while static Number.* methods (isInteger, isFinite, isNaN, isSafeInteger, parseInt, parseFloat) can only be used on Number itself. [S1]
🧠 핵심 개념 (Core concepts)
- Basic methods work on any number —
toString(),toExponential(),toFixed(),toPrecision(),valueOf(). [S1] - Static methods only on
Number—Number.isFinite(),Number.isInteger(),Number.isNaN(),Number.isSafeInteger(),Number.parseInt(),Number.parseFloat(). [S1] toString()— returns a number as a string; accepts a radix. [S1]toFixed()— returns a string with a specified number of decimals; perfect for working with money. [S1]toPrecision()— returns a string with a number written to a specified length. [S1]- Conversion functions —
Number(),parseInt(),parseFloat()convert variables to numbers;NaNis returned when conversion fails. [S1] - Methods cannot be used on variables for statics —
Number.isInteger()etc. must be called onNumber; calling on a variable throws a TypeError. [S1] - Safe integers — range is -(2⁵³ - 1) to +(2⁵³ - 1);
9007199254740991is safe,9007199254740992is not. [S1]
🧩 추출된 패턴 (Extracted patterns)
- Format money —
value.toFixed(2)to render two decimal places. [S1] - Parse leading number from text —
parseInt("10 years")/parseFloat("10.33")extract a number from the front of a string. [S1] - Validate before use —
Number.isInteger()/Number.isSafeInteger()/Number.isNaN()to check values. [S1]
📖 세부 내용 (Details)
Basic Methods can be used on any number: toString(), toExponential(), toFixed(), toPrecision(), valueOf(). Static Methods can only be used on Number: Number.isFinite(), Number.isInteger(), Number.isNaN(), Number.isSafeInteger(), Number.parseInt(), Number.parseFloat(). [S1]
toString() — returns a number as a string; can take a radix. [S1]
let x = 123;
x.toString();
(123).toString();
(100 + 23).toString();
let x = 123;
let text = x.toString(2);
toExponential() — returns a string with a number rounded and written using exponential notation. [S1]
let x = 9.656;
x.toExponential(2);
x.toExponential(4);
x.toExponential(6);
toFixed() — returns a string with the number written with a specified number of decimals; perfect for working with money. [S1]
let x = 9.656;
x.toFixed(0);
x.toFixed(2);
x.toFixed(4);
x.toFixed(6);
toPrecision() — returns a string with a number written with a specified length. [S1]
let x = 9.656;
x.toPrecision();
x.toPrecision(2);
x.toPrecision(4);
x.toPrecision(6);
valueOf() — returns a number as a number; used internally in JavaScript to convert Number objects to primitive values. [S1]
let x = 123;
x.valueOf();
(123).valueOf();
(100 + 23).valueOf();
Converting Variables to Numbers — three methods are available: [S1]
| Method | Description |
|---|---|
| Number() | Converts argument to number |
| parseFloat() | Parses argument, returns floating point |
| parseInt() | Parses argument, returns whole number |
Number() — converts its argument to a number. [S1]
Number(true);
Number(false);
Number("10");
Number(" 10");
Number("10 ");
Number(" 10 ");
Number("10.33");
Number("10,33");
Number("10 33");
Number("John");
Number() Used on Dates — converts a date to milliseconds. [S1]
Number(new Date("1970-01-01"))
Number(new Date("1970-01-02"))
Number(new Date("2017-09-30"))
parseInt() — parses and returns a whole number. [S1]
parseInt("-10");
parseInt("-10.33");
parseInt("10");
parseInt("10.33");
parseInt("10 20 30");
parseInt("10 years");
parseInt("years 10");
parseFloat() — parses and returns a floating point number. [S1]
parseFloat("10");
parseFloat("10.33");
parseFloat("10 20 30");
parseFloat("10 years");
parseFloat("years 10");
Number Object Methods (static): [S1]
| Method | Description |
|---|---|
| Number.isInteger() | Returns true if argument is integer |
| Number.isNaN() | Returns true if argument is NaN |
| Number.isFinite() | Returns true if not Infinity or NaN |
| Number.isSafeInteger() | Returns true if safe integer |
| Number.parseFloat() | Converts string to number |
| Number.parseInt() | Converts string to whole number |
Number methods can only be accessed like Number.isInteger(); calling them on a variable produces a TypeError ("X.isInteger is not a function"). Number.isNaN() is the preferred way to check for equality with NaN. [S1]
Number.isInteger() [S1]
Number.isInteger(10);
Number.isInteger(10.5);
Number.isFinite() [S1]
Number.isFinite(123);
Number.isNaN() [S1]
Number.isNaN(123);
Number.isSafeInteger() — safe integer range is -(2⁵³ - 1) to +(2⁵³ - 1). [S1]
Number.isSafeInteger(10);
Number.isSafeInteger(12345678901234567890);
Number.parseFloat() [S1]
Number.parseFloat("10");
Number.parseFloat("10.33");
Number.parseFloat("10 20 30");
Number.parseFloat("10 years");
Number.parseFloat("years 10");
Number.parseInt() [S1]
Number.parseInt("-10");
Number.parseInt("-10.33");
Number.parseInt("10");
Number.parseInt("10.33");
Number.parseInt("10 20 30");
Number.parseInt("10 years");
Number.parseInt("years 10");
🛠️ 적용 사례 (Applied in summary)
The page's own snippets are the canonical applied examples — formatting 9.656 with toFixed/toPrecision/toExponential, converting strings and dates with Number(), parsing with parseInt/parseFloat, and validating with the static Number.* methods. No external project/commit applications found in the source.
💻 코드 패턴 (Code patterns)
Format for money:
let x = 9.656;
x.toFixed(2);
Parse a number from text:
parseInt("10 years");
parseFloat("10.33");
Validate a value:
Number.isInteger(10);
Number.isSafeInteger(9007199254740991);
⚖️ 비교 및 선택 기준 (Comparison & decision criteria)
Number()vsparseInt()vsparseFloat()—Number()converts the whole argument (returns NaN if it is not fully numeric, e.g."10 33");parseInt()returns a whole number from the leading numeric portion;parseFloat()returns a floating point from the leading numeric portion. [S1]- Basic vs static methods — basic methods (
toFixed, etc.) are called on a number value; static methods (Number.isInteger, etc.) must be called onNumberitself or they throw a TypeError. [S1] Number.isNaN()is preferred for checking equality with NaN. [S1]
⚖️ 모순 및 업데이트 (Contradictions & updates)
No contradictions found in the source.
✅ 검증 상태 및 신뢰도
- 상태: draft
- 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
- 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
- 신뢰 점수: 0.89
- 중복 검사 결과: 신규 생성 (New discovery)
🔗 지식 그래프 (Knowledge Graph)
- 상위/루트: JavaScript Tutorial
- 관련 개념: JavaScript Numbers, JavaScript Number Properties, JavaScript Data Types, JavaScript Operators
- 참조 맥락: Referenced whenever formatting numbers for display or converting strings/dates into numeric values.
📚 출처 (Sources)
- [S1] W3Schools — JavaScript Number Methods — https://www.w3schools.com/js/js_number_methods.asp
📝 변경 이력 (Change history)
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Number Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).