array.indexOf(element) [immutable] - 불변
let word = ['Security', 'Info', 'World'];
word.indexOf('Security');
0 // 0번째 index
word.indexOf('Info');
1 // 1번째 index
word.indexOf('World');
2 // 2번째 index
word.indexOf('security');
-1 // 없으므로 -1
word.indexOf('address');
-1 // 없으므로 -1
-
찾고자 하는 element
-
리턴 값 : 배열 내에 최초로 element가 등장하는 index, 만일 없으면 -1을 리턴
array.includes(element) [immutable] - 불변
let word = ['Security', 'Info', 'World'];
word.includes('Security');
true
word.includes('Info');
true
word.includes('World');
true
word.includes('security');
false
word.includes('address');
false
-
찾고자 하는 element
-
리턴 값 : 배열 내에 element가 있으면 true, 없으면 false
array.join([separatorString]) [immutable] - 불변
let word = ['Security', 'Info', 'World'];
word.join('');
"SecurityInfoWorld"
word.join(', ');
"Security, Info, World"
word.join('+');
"Security+Info+World"
word.join('-');
"Security-Info-World"
word.join();
"Security,Info,World"
-
연결할 문자열 (기본값은 ",")
-
리턴 값 : 연결 문자와 element를 연결한 문자열
'CodeStates > └ JavaScript(Pre)' 카테고리의 다른 글
Scope (0) | 2020.06.25 |
---|---|
재귀 함수 (0) | 2020.06.22 |
reduce (0) | 2020.06.20 |
filter (0) | 2020.06.20 |
map (0) | 2020.06.20 |
댓글