참고강의
array
array.push()
array.pop()
array.unshift()
array.shift()
array.splice(n,m)
array.slice(n,m)
array.splice(n,m,x)
let arr = ["나는", "철수", "입니다"]
arr.splice(1,0,"대한민국","소방관")
console.log(arr)
arr1.concat(arr2)
array.forEach(arr)
let users = ["Kim", "Lee", "Park"]
users.forEach((userName, index, arr) => {
console.log(userName)
console.log(index)
console.log(arr)
})
array.indexOf(text)
array.includes(text)
array.find(fn)
let arr = [1,2,3,4,5];
const result = arr.find((item) => {
return item % 2 === 0;
})
console.log(result)
let userList = [
{ name : "Kim", age : 30 },
{ name : "Lee", age : 26 },
{ name : "Park", age : 22 },
];
const result = userList.find((user) => {
if(user.age < 25){
console.log(user)
}
})
array.filter(fn)
const result = userList.filter((user) => {
if(user.age < 28
console.log(user)
}
})
array.map(fn)
const newUserList = userList.map((user, index) => {
return Object.assgin({}, user, {
id : index+1,
})
})
array.sort()
array.sort(((a,b) => a - b))
array.reverse()
array.reduce((누적 계산값, 초기값) => {
return 누적 계산값 + 현재값
},초기값?)
let arr = [1,2,3,4,5]
const result = arr.reduce((prev, currnet) => {
return prev + currnet
},0)
console.log(result)