png created by here
요즘 헷갈리는 기초 용어가 많아 자바스크립트 공부할 때마다 막히는 부분이 많다...ㅠㅠ
더 이상 용어 정리를 미루다가는 큰일날 것 같아서 정리한다!!!
찾았던 거 또 찾지 말고 정리하고 외우자 좀
Statement
In a computer programming language, a statement is a line of code commanding a task.
Every program consists of a sequence of statements.
출처: https://developer.mozilla.org/en-US/docs/Glossary/Statement
statement = 작업을 수행하도록 하는 코드를 의미
코드 구성 요소를 하나하나 분석하는 것
우리가 영어문장으로 문법 공부할 때
I like pizza.
(주어 - 나는) (동사 - 좋아한다) (목적어 - 피자를)
이렇게 분석하는데 이런식으로 코드를 분석한다는 의미이다.
컴파일링은 개발자들이 작성한 코드 파일을 컴퓨터가 이해할 수 있는 기계어로 번역하는 것을 말한다.
*기계어란 쉽게 말해 110101010...이런 뭔가 굉장히 기계스러운....그런 언어를 의미한다.
컴파일링은 영어 문장 공부에 비유하면 아예 한국어로 자연스럽게 번역을 하는 것이라고 할 수 있다.
I like pizza.
나는 피자를 좋아한다.
출처 및 자세한 설명: https://chlolisher.tistory.com/98
코드를 한 줄씩 파싱하는(분석하는) 프로그램
** 자바스크립트는 인터프리터 언어로 런타임(프로그램 실행 시)시 코드를 한줄씩 파싱한다.
출처: https://www.yalco.kr/37_devterms/
Function
Functions are one of the fundamental building blocks in JavaScript.
A function is...a set of statements that performs a task or calculates a value,
but for a procedure to qualify as a function, it should take some input and return an output
where there is some obvious relationship between the input and the output.
출처: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions
함수는 어떤 작업을 하거나 값을 연산(계산)하는 statement 세트이다.
함수는 입력값(input)을 받아 출력값(output)을 반환(return)하는 형태를 가지고 있다.
return값을 적지 않으면 undefined를 return한다.
//function 함수이름(파라미터이름1, 파라미터이름2){
```statements```
return 반환값;(없으면 undefined)
}
function add(a,b){
return a+b;
}
add(1,2)//실행
console.log(add(1,2));
function add(a,b){
return a+b;
}
//3이 콘솔에 출력
const add = function(a,b){
return a+b;
}
add();
변수()
형식으로 함수 사용이 가능const add = (a, b)=> {return a+b;}
add();
this 값이 함수 실행 시 결정된다.(this 설명 포스팅 곧 작성 예정)
함수 표현식은 .(Dot notation)앞의 객체가 this가 된다.
화살표 함수는 상위 스코프가 this가 된다.
argument 자동 생성x
new 사용 불가(생성자 함수로 사용 불가)
출처: https://velog.io/@bigbrothershin/%EC%98%A4%EB%8A%98-%EA%B3%B5%EB%B6%80%ED%95%A0-%EA%B2%832020.1.30
https://sewonzzang.tistory.com/21
https://hanamon.kr/javascript-%ED%95%A8%EC%88%98-%EA%B8%B0%EC%B4%88/
https://preamtree.tistory.com/116
함수를 구현하는 쪽과(함수 선언 부분) 함수를 사용하는 쪽을(함수 실행문) 매개(연결)하는 변수
함수 사용자가 매개변수에 넣는 값에 해당하는 Array 형태의 객체(유사 배열)
function add(a,b){ //a,b는 parameter
return a+b;
}
add(1,2);//1,2는 argument
** 화살표 함수에서 argument 사용하는 법: ... 활용하기
const printFirstArg = (...args) => {
console.log(args[0]);
}
printFirstArg(1,2,3);//1
출처: https://m.blog.naver.com/kyozoo72/221725465704
https://bubobubo003.tistory.com/55
업데이트 예정
https://preamtree.tistory.com/113