JavaScript

Script 함수

코딩공부 2020. 9. 6. 21:19

ES6버전 이전

 

function hello(name){
	console.log('Hello, ' +name + '!');
}

hello('coding'); //Hello, coding!
function add(a,b){
	return a+b;
}


const sum = add(1,2);

console.log(sum); //3

 

 

ES6버전 이후 

 

fucntion hello(name){
	return 'Hello ${name}!';
}

const result = hello('Coding');

console.log(result); // Hello Coding!

 

화살표 함수

const add = (a, b) => {
	return a+b;
}

const sum = add(1, 2);
console.log(sun); //3
const add = (a, b) => a+b;

const sum = add(1, 2);
console.log(sum); // 3

 

function hello = (name) =>{
	console.log('Hello, ${name}!');
}

hello('coding'); //Hello, coding!

 

'JavaScript' 카테고리의 다른 글

객체 - Getter와 Setter 함수  (0) 2020.09.07
객체 - 객체 안에 함수 넣기  (0) 2020.09.07
객체 - 비구조화 할당  (0) 2020.09.07
객체  (0) 2020.09.07
var, let, const 의 차이점  (0) 2020.09.06