Callback vs Promise vs AsyncAwait
F5B1 ํ ํ๋ก์ ํธ ๋ฐํ ์ ๋ฆฌ
arr = [1,2,3,4,5]
arr.splice( 2 ) // [ 3,4,5 ]
arr // [ 1,2 ] , ์ ๊ฑฐ๋ ๊ฒฐ๊ณผ๋ง ๋ค๊ณ ์จ๋ค!
arr = [ 1,2,3,4,5 ]
arr.splice(1,2) // [ 2,3 ], 1๋ฒ์งธ ์ธ๋ฑ์ค๋ถํฐ 2๊ธ์๋ฅผ ๊ฐ์ ธ์จ๋ค
arr //[ 1,4,5 ]
arr = [1,2,3,4,5]
arr.splice(1,2,0) // [2,3], ์ธ๋ฒ์งธ ์ธ์๋ ๋น ์ง ๋ฐ์ดํฐ์ 0์ถ๊ฐ
arr //[1,0,4,5]
Array.prototype.splice() - JavaScript | MDN
let str = "jonghyun, taemin, keybum, minho"
str.indexOf('taemin') // ์ถ๋ ฅ๊ฐ: 10 / 10๋ฒ์งธ ์ธ๋ฑ์ค๋ถํฐ ์กด์ฌ
str.indexOf('onew') // ์ถ๋ ฅ๊ฐ: -1 / ๋ฌธ์์ด์ ์กด์ฌํ์ง ์์ผ๋ฏ๋ก -1 ์ถ๋ ฅ
str.indexOf(',', 9) // ์ถ๋ ฅ๊ฐ: 16 / 9๋ฒ์งธ ์ธ๋ฑ์ค์์ ์์ํด์ ','๋ฅผ ์ฐพ์
"SHINee World".indexOf("SHINee") !== -1; // true
"SHINee World".indexOf("shinee") !== -1; // false, indexOf()๋ ๋์๋ฌธ์๋ ๊ตฌ๋ถํ๋ค.
var str = 'This is the way';
var count = 0;
var pos = str.indexOf('i'); //pos๋ 2์ ๊ฐ์ ๊ฐ์ง๋๋ค.
while (pos !== -1) {
count++;
pos = str.indexOf('i', pos + 1); // ์ฒซ ๋ฒ์งธ i ์ดํ์ ์ธ๋ฑ์ค๋ถํฐ i๋ฅผ ์ฐพ์ต๋๋ค.
}
console.log(count);
String.prototype.indexOf() - JavaScript | MDN