[JavaScript] Expression vs Statement

cho yunsu·2021년 3월 1일
0

Expression: value를 리턴하는 것.

function add(a,b){return a+b;}
const A = add(1,2)

console.log(A) //3

Statement: order, intruction.. 리턴하는 것이 없다.
statement를 변수로 저장할 수 없다.
ex.if(true){}, else, else if, for, while...

const thing = if(true){} // error
//statement를 변수로 저장할 수 없다.

functional expression vs functional declaration

const handsome = add(1,2);

function add(a,b){return a+b;} // functional declaration
const add = (a,b)=>a+b; // error functional expression

console.log(handsome)
profile
Growing Developer!!

0개의 댓글