9609c04755
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>
137 lines
5.7 KiB
Markdown
137 lines
5.7 KiB
Markdown
---
|
|
id: javascript-function-parameters
|
|
title: "JavaScript Function Parameters"
|
|
category: "Frontend"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["function parameters", "arguments", "parameters vs arguments", "default parameters", "parameter rules", "function input"]
|
|
duplicate_of: ""
|
|
source_trust_level: "B"
|
|
confidence_score: 0.87
|
|
created_at: 2026-06-23
|
|
updated_at: 2026-06-23
|
|
review_reason: ""
|
|
merge_history: []
|
|
tags: ["javascript", "js", "web", "frontend", "w3schools", "functions", "parameters"]
|
|
raw_sources: ["https://www.w3schools.com/js/js_function_parameters.asp"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[JavaScript Function Parameters]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
Parameters are the named inputs a function declares in its parentheses; arguments are the real values passed in when it is called — and JavaScript checks neither their types nor their count. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **Parameters pass values in** — parameters allow you to send values to a function and are listed inside the parentheses in the function definition. [S1]
|
|
- **Parameters vs arguments** — parameters are the names listed in the function definition; arguments are the real values passed to and received by the function. [S1]
|
|
- **No type or count enforcement** — JavaScript function definitions do not specify data types for parameters, do not perform type checking on arguments, and do not check the number of arguments received. [S1]
|
|
- **Missing arguments give wrong results** — accessing a function with an incorrect (missing) parameter can return an incorrect answer. [S1]
|
|
- **Default parameter values** — ECMAScript 2015 allows function parameters to have default values, used when no argument is provided. [S1]
|
|
|
|
## 🧩 추출된 패턴 (Extracted patterns)
|
|
- **One or many parameters** — declare a single parameter, or as many as needed separated by commas. [S1]
|
|
- **Default fallback** — `function f(x, y = 10)` supplies `10` when the second argument is omitted. [S1]
|
|
- **No safety net** — because there is no type/count checking, a missing argument silently flows through (e.g. `toCelsius()` with no input). [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
**Parameters (Function Input)** — parameters allow you to pass (send) values to a function; they are listed inside the parentheses in the function definition. [S1]
|
|
|
|
**Functions with One Parameter** — a function can have one parameter: [S1]
|
|
```javascript
|
|
function sayHello(name) {
|
|
return "Hello " + name;
|
|
}
|
|
|
|
let greeting = sayHello("John");
|
|
```
|
|
|
|
A single-parameter conversion: [S1]
|
|
```javascript
|
|
function toCelsius(fahrenheit) {
|
|
return (5 / 9) * (fahrenheit - 32);
|
|
}
|
|
|
|
let value = toCelsius(77);
|
|
```
|
|
|
|
**Functions with Multiple Parameters** — you can add as many parameters as you want, separated by commas: [S1]
|
|
```javascript
|
|
function multiply(a, b) {
|
|
return a * b;
|
|
}
|
|
|
|
let result = multiply(4, 5);
|
|
```
|
|
```javascript
|
|
function fullName(firstName, lastName) {
|
|
return firstName + " " + lastName;
|
|
}
|
|
|
|
let name = fullName("John", "Doe");
|
|
```
|
|
|
|
**Parameters vs. Arguments** — parameters are the names listed in the function definition; arguments are the real values passed to and received by the function. [S1]
|
|
|
|
**Parameter Rules** — JavaScript function definitions do not specify data types for parameters; JavaScript functions do not perform type checking on the arguments; JavaScript functions do not check the number of arguments received. [S1]
|
|
|
|
**Incorrect Parameters** — accessing a function with an incorrect (missing) parameter can return an incorrect answer: [S1]
|
|
```javascript
|
|
function toCelsius(fahrenheit) {
|
|
return (5/9) * (fahrenheit-32);
|
|
}
|
|
|
|
let value = toCelsius();
|
|
```
|
|
|
|
**Default Parameter Values** — ECMAScript 2015 allows function parameters to have default values; the default value is used if no argument is provided: [S1]
|
|
```javascript
|
|
function myFunction(x, y = 10) {
|
|
return x + y;
|
|
}
|
|
myFunction(5);
|
|
```
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
The page's own snippets are the canonical applied examples — single-parameter `sayHello(name)` and `toCelsius(fahrenheit)`, multi-parameter `multiply(a, b)` and `fullName(firstName, lastName)`, the missing-argument `toCelsius()` case, and the default-parameter `myFunction(x, y = 10)`. No external project/commit applications found in the source.
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Multiple parameters (language: JavaScript):
|
|
```javascript
|
|
function fullName(firstName, lastName) {
|
|
return firstName + " " + lastName;
|
|
}
|
|
|
|
let name = fullName("John", "Doe");
|
|
```
|
|
Default parameter value:
|
|
```javascript
|
|
function myFunction(x, y = 10) {
|
|
return x + y;
|
|
}
|
|
myFunction(5);
|
|
```
|
|
|
|
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
|
No contradictions found in the source.
|
|
|
|
## ✅ 검증 상태 및 신뢰도
|
|
- **상태:** draft
|
|
- **검증 단계:** conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
|
|
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
|
- **신뢰 점수:** 0.87
|
|
- **중복 검사 결과:** 신규 생성 (New discovery)
|
|
|
|
## 🔗 지식 그래프 (Knowledge Graph)
|
|
- **상위/루트:** [[JavaScript Tutorial]]
|
|
- **관련 개념:** [[JavaScript Functions]], [[JavaScript Function Definitions]], [[JavaScript Function Invocation]], [[JavaScript Function Returns]]
|
|
- **참조 맥락:** Referenced when designing a function's inputs, defaults, and how callers supply arguments.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — JavaScript Function Parameters — https://www.w3schools.com/js/js_function_parameters.asp
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-06-23: Initial draft synthesized from the W3Schools "JavaScript Function Parameters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|