본문 바로가기
프로그래밍

2023-05-13 javascript

by AandBB 2023. 5. 13.
//delete first element in array
members.shift();

//delete last element in array
members.pop();

//add element as first element of array
members.unshift('Hello');

//add element as last element of array
members.push('Bye');

 

brands.indexOf('Kakao');

Find 'Kakao' in array. If the array has it, then the array returns the index of it. If not, the array returns -1. Moreover, if the array has same multiple elements, then it returns the first index of them.

brands.lastIndexOf('Kakao');

Find 'Kakao' in array from the last element of array.

brands.includes('Kakao');

Check if array has 'Kakao' as an element. if the array has it, then it returns true. If not, it returns false.

brands.reverse();

reverse the order of array

'프로그래밍' 카테고리의 다른 글

2023-06-13 javascript_string  (0) 2023.06.13
2023-05-16 javascript_array  (0) 2023.05.16
2023-05-11 javascript  (0) 2023.05.11
2023-05-08 javascript  (0) 2023.05.08
2023-05-07 javascript  (0) 2023.05.07