문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
wiki:javascript:javascript_note:js_arrow_function [2021/04/26 14:37] emblim98 만듦 |
wiki:javascript:javascript_note:js_arrow_function [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 53: | 줄 53: | ||
| =====Arrow Function With Parameters: | =====Arrow Function With Parameters: | ||
| <code javascript> | <code javascript> | ||
| + | let hello; | ||
| + | hello = (val) => "Hello " + val; | ||
| + | |||
| + | document.getElementById(" | ||
| </ | </ | ||
| \\ | \\ | ||
| 줄 60: | 줄 64: | ||
| =====Arrow Function Without Parentheses===== | =====Arrow Function Without Parentheses===== | ||
| <code javascript> | <code javascript> | ||
| + | let hello; | ||
| + | hello = val => "Hello " + val; | ||
| + | |||
| + | document.getElementById(" | ||
| </ | </ | ||
| 줄 83: | 줄 91: | ||
| 일반 함수를 사용하면, | 일반 함수를 사용하면, | ||
| <code javascript> | <code javascript> | ||
| + | let hello; | ||
| + | hello = function () { | ||
| + | document.getElementById(" | ||
| + | } | ||
| + | |||
| + | // The window object calls the function: | ||
| + | window.addEventListener(" | ||
| + | |||
| + | // A button objects calls the function: | ||
| + | document.getElementById(" | ||
| + | // [object Window][object HTMLButtonElement] | ||
| </ | </ | ||
| \\ | \\ | ||
| + | |||
| 화살표 함수를 사용하면, | 화살표 함수를 사용하면, | ||
| \\ | \\ | ||
| + | <code javascript> | ||
| + | let hello; | ||
| + | |||
| + | hello = () => { | ||
| + | document.getElementById(" | ||
| + | } | ||
| + | |||
| + | // The window object calls the function: | ||
| + | window.addEventListener(" | ||
| + | |||
| + | // A button objects calls the function: | ||
| + | document.getElementById(" | ||
| + | // [object Window][object Window] | ||
| + | </ | ||
| 함수로 작업할 때 이러한 차이점을 기억하십시오.\\ | 함수로 작업할 때 이러한 차이점을 기억하십시오.\\ | ||
| 때로는 일반 함수의 동작이 원하는 것이지만, | 때로는 일반 함수의 동작이 원하는 것이지만, | ||