null : 없음
undefined : 실제로 값이 아직 설정되지 않음
== : 타입 검사는 하지않음
=== : 타입 검사도 함
+ : 문자열 붙이기도 가능하다.
함수
function add(a, b){
return a + b;
}
const add = (a, b) => {
return a + b;
}
객체 비구조화 할당
function print(hero) {
const { alias, name, actor } = hero;
const text = `${alias}(${name}) 역할을 맡은 배우는 ${actor} 입니다.`;
console.log(text);
}
자바스크립트의 getter , setter
배열 내장 함수
const superheroes = ['아이언맨', '캡틴 아메리카', '토르', '닥터 스트레인지'];
superheroes.forEach(hero => {
console.log(hero);
});
const array = [1, 2, 3, 4, 5, 6, 7, 8];
const square = n => n * n;
const squared = array.map(square); // 변화를 주고 싶은 함수를 넣어준다.
console.log(squared);
const todos = [
{
id: 1,
text: '자바스크립트 입문',
done: true
},
{
id: 2,
text: '함수 배우기',
done: true
},
{
id: 3,
text: '객체와 배열 배우기',
done: true
},
{
id: 4,
text: '배열 내장함수 배우기',
done: false
}
];
const index = todos.findIndex(todo => todo.id === 3);
console.log(index);
const todo = todos.find(todo => todo.id === 3);
const tasksNotDone = todos.filter(todo => todo.done === false);