Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- react quill custom
- JPA Insert
- Spring JPA
- spring security
- react Page
- 텍스트가 많은 경우
- react Quill
- react react-router-dom v6
- spring builder
- Spring Controller return
- react link
- react
- Docker Windows 설치
- step 테이블
- Spring DTO
- editor Quill
- SpringBatch 스키마
- javascript 함수
- javascrpit 기초
- Spring Entity
- react jsx if
- javascript 기초
- Javascript
- springbatch chunk
- react forwardRef
- Spring CORS
- springbatch
- 코드 중복제거
- spring
- JPA Update\
Archives
- Today
- Total
천천히 알아보는 코딩공부
javascript 기초 1 - 함수(2) 본문
○ length 프로퍼티
function func0() {
}
function func0(x) {
return x;
}
function func0(x, y) {
return x + y;
}
function func0(x, y, z) {
return x + y + z;
}
console.log('func0.length -' + func0.length); // func0.length - 0
console.log('func1.length -' + func1.length); // func1.length - 1
console.log('func2.length -' + func2.length); // func2.length - 2
console.log('func3.length -' + func3.length); // func3.length - 3
○ 콜백함수
- 자바스크립트 함수 표현식에서 함수 이름은 꼭 붙이지 않아도 되는 선택사항이다.
<html><body>
<script>
window.onload = function() {
alert('this is the callback function');
};
</script>
</html></body>
- 웹 페이지가 로딩될 때 우리가 등록한 이벤트 핸들러가 호출되면서 경고창이 뜨게 된다.
○ 즉시 실행 함수
- 함수를 정의함과 동시에 바로 실행하는 함수
- 최초 한 번의 실행만을 필요로하는 초기화 코드 부분 등에 사용할 수 있다.
(function (name){
console.log('This is the immediate function ->' + name);
))('foo');
○ 내부 함수
- 함수 코드 내부에서도 다시 함수 정의가 가능하다. 이렇게 함수 내부의 정의된 함수를 내부 함수라고 부른다.
function parent() {
var a = 100;
var b = 200;
function child() {
var b = 300;
console.log(a);
console.log(b);
}
child();
}
parent();
child();
출력결과
100 300 Uncaught ReferenceError: child is not defined |
- 내부 함수는 자신을 둘러싼 외부 함수의 변수에 접근 가능하다.
○ 함수를 리턴하는 함수
var self = function() {
console.log('a');
return function() {
console.log('b');
}
}
self = self(); // a
self(); // b
'JavaScript > 기초' 카테고리의 다른 글
javascript 기초 1 - 함수(4) (0) | 2022.05.12 |
---|---|
javascript 기초 1 - 함수(3) (0) | 2022.05.11 |
javascript 기초 1 - 함수(1) (0) | 2022.05.11 |
javascript 연산자 (0) | 2022.04.21 |
javascript 배열 (0) | 2022.04.19 |
Comments