www.youtube.com/watch?v=yOdAVDuHUKQ
[looping]
1. for( ){ }
2. for( let 임의의 변수명 of 정의된 변수명(배열) ){ }
3. forEach( ①콜백함수(3가지의 인자: value, index, array), ②Argument ){ }
[Addition, deletion, copy]
1. add an item to the end : push( )
2. remove an item from the end : pop( )
3. add an item to the beginning : unshift( )
4. remove an item from the beginning : shift( )
** push와 pop은 마지막 데이터를 사용하기 때문에 비교적 빠르다. 하지만 unshift와 shift는 앞에서 부터 빼고 더하기 때문에 느리다.
5. remove an item by index position : splice(start: number, deleteCount: number(몇개를 지울지), addData(지워진 자리에 데이터를 추가) )
6. combine two arrays : concat( 변수명(배열) )
ex: const fruit = [ 1, 2 ] const fruit2 = [ 3, 4 ] const newfruit = fruit.concat( fruit2 )
[search]
fruit.indexOf( 찾고자 하는 데이터 ) : 찾고자 하는 데이터가 있으면 해당 데이터의 index값을 숫자로 반환 없으면 -1을 반환함.
fruit.lastIndexOf( ) 찾고자 하는 데이터가 여러개인 경우 제일 뒤에 있는 데이터의
fruit.includes( 찾고자 하는 데이터 ) : 찾고자 하는 데이터를 찾으면 true, 없으면 false를 반환함.
www.youtube.com/watch?v=3CUjtKJ7PJg&t=151s
8. make a string out of an array : join( '구분자(seperator)' )
const fruits = [ 'apple', 'banna', 'orange' ]
const result = fruits.join( )
9. make an array out of a string : split( )
const fruits = 'apple', 'banna', 'orange';
const result = fruits.split( )
'자바스크립트' 카테고리의 다른 글
Object literal (객체 리터럴) (0) | 2020.09.16 |
---|---|
Spread Syntax - JavaScript Tutorial (0) | 2020.09.12 |
JavaScript 정보 (ES6: ECMAScript) (0) | 2020.09.02 |
ECMAScript 와 JavaScript의 차이점 (0) | 2020.09.02 |
ES6: 구조분해 할당(Destructuring) (0) | 2020.08.28 |
댓글