let arr = []; // 배열 리터럴

// 이런식으로 모든 타입을 다룰 수 있다.
let arr = [1,"2". true, null, undefined, {}, [], function() {}] 

let person = {
	name: "박정수",
	age: 25,
  tall : 180
}

const personKeys = Object.keys(person);

console.log(personKeys);

for(let i=0; i<personKeys.length; i++){
	const curKey = personKeys[i];
	const curValue = person[curKey];

	console.log(`${curKey} : ${curValue}`);  // 이런식으로 객체도 순회 가능
}

Untitled

let person = {
	name: "박정수",
	age: 25,
  tall : 180
}

const personValue = Object.values(person);

for(let i = 0; i< personValues.length; i++){
	console.log(personValues[i]);
}

배열 내장함수

const arr = [1,2,3,4];
const newArr = []

arr.forEach((elm) => {
	newArr.push(elm * 2);
});
console.log(newArr);

배열의 각각 모든 요소에 대해서 한 번씩 콜백 함수를 수행한다 생각하면 된다.

const arr = [1,2,3,4];
const newArr = arr.map((elm)=>{
	return elm * 2
})

console.log(newArr);

Untitled