javascript & jQuery

javascript array의 function들

k9e4h 2016. 8. 11. 15:34

http://www.w3schools.com/js/js_array_methods.asp




toString() converts an array to a string of (comma separated) array values.


join() method also joins all array elements into a string.


sort() 정렬


reverse() 역순 정렬


pop() 배열 끝점의 원소를 제거


push() method adds a new element to an array (at the end), 인자로 전달된 값을 배열에 추가


shift() method removes the first array element and "shifts" all other elements to a lower index, 배열의 첫번째 원소 제거


unshift() method adds a new element to an array (at the beginning), and "unshifts" older elements, 인자로 전달한 값을 배열의 첫번째 원소로 추가하고 기존 값들의 index를 1씩 증가


 elements can be deleted by using the JavaScript operator delete:

delete는 object 자체를 없애는 것 / Array의 element를 없애는게 아니다.


splice() method can be used to add new items to an array & remove도 가능, 첫번째 인자에 해당하는 원소부터 두번째 인자에 해당하는 원소의 숫자만큼 값을 배열로부터 제거한 후에 리턴한다. 그리고 세번째 인자로부터 전달된 인자들을 첫번째 인자의 원소 뒤에 추가한다.


concat() method creates a new array by concatenating two arrays, 인자로 전달된 값을 추가


valueOf() method is the default behavior for an array. It converts an array to a primitive value



반응형

'javascript & jQuery' 카테고리의 다른 글

javascript module require()  (0) 2016.08.16
javascript와 jquery의 차이  (0) 2016.08.11
Object.keys()  (0) 2016.08.10
AmChartJS API  (0) 2016.08.09
HTML 메일 보내기  (0) 2016.08.08