join(separator?: string): string;
const fruits = ['a','b','c'];
const jj = fruit.join('')
console.log(jj) // 'abc'
split(separaotr?:string):T[]
const fruits = ['a','b','c'];
const jj = fruit.join('')
console.log(jj) // 'abc'
reverse():T[]
const arr = ['a','b','c'];
const result = arr.reverse()
console.log(result) // ['c','b','a']
console.log(arr) // ['c','b','a']
splice(start: number, deleteCount?: number): T[]
const arr = ['a','b','c','d','e'];
const result = arr.splice(0,2)
console.log(result) // ['a','b']
console.log(arr) // ['c','e','e']
const arr2 = ['a','b','c','d','e'];
const result2 = arr.splice(0,2,['aa'])
console.log(result) // ['a','b']
console.log(arr) // ['aa','c','e','e']
slice(start?: number, end?: number): T[]
const arr = ['a','b','c','d','e'];
const result = arr.slice(2,5)
console.log(result) // ['c','d','e']
console.log(arr) // ['a','b','c','d','e']
find(value: T, index: number, array: T[]) => unknown, thisArg?: any): number | undefined
const students = [
{name:'서은광',score:81},
{name:'이민혁',score:100},
{name:'이창섭',score:30},
{name:'임현식',score:80},
{name:'프니엘',score:90},
{name:'육성재',score:95}
]
const result = students.find((student)=>{
return student.score === 100
})
console.log(result)//1
filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]
const students = [
{name:'서은광',score:81},
{name:'이민혁',score:100},
{name:'이창섭',score:30},
{name:'임현식',score:80},
{name:'프니엘',score:90},
{name:'육성재',score:95}
]
const result = students.filter((student)=>{
return student.score >= 95
})
console.log(result)// [{name:'이민혁',score:'100'},{name:'육성재',score:95}]
Map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]
const students = [
{name:'서은광',score:81},
{name:'이민혁',score:100},
{name:'이창섭',score:30},
{name:'임현식',score:80},
{name:'프니엘',score:90},
{name:'육성재',score:95}
]
const result = students.map((student)=>{
return student.score
})
console.log(result)// [81,100,30,80,90,95]
some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean
const students = [
{name:'서은광',score:81},
{name:'이민혁',score:100},
{name:'이창섭',score:30},
{name:'임현식',score:80},
{name:'프니엘',score:90},
{name:'육성재',score:95}
]
const result = students.some((student)=>{
student.score < 50
})
console.log(result)// true
every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean
const students = [
{name:'서은광',score:81},
{name:'이민혁',score:100},
{name:'이창섭',score:30},
{name:'임현식',score:80},
{name:'프니엘',score:90},
{name:'육성재',score:95}
]
const result = students.some((student)=>{
student.score > 50
})
console.log(result)// false
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T
const students = [
{name:'서은광',score:81},
{name:'이민혁',score:100},
{name:'이창섭',score:30},
{name:'임현식',score:80},
{name:'프니엘',score:90},
{name:'육성재',score:95}
]
// 평균 구하기
const result = students.reduce((acc,curr)=>{
return acc+curr.score
},0) // initail value 0
console.log(result)// 476
console.log(result/students.length)
sort(compareFn?: (a: T, b: T) => number): this
// 오름차순
const arr = [1,2,3,4]
const result = arr.sort((a,b)=> a-b)
// 내림차순
const arr2 = [1,2,3,4]
const result = arr2.sort((a,b)=> b-a)