JS常用方法

一、數(shù)組常用方法

1.push()

尾部追加,類(lèi)似于壓棧,原數(shù)組會(huì)變。

const arr = [1, 2, 3]
arr.push(8)
console.log(arr) // [1, 2, 3, 8]

2.pop()

尾部彈出,類(lèi)似于出棧,原數(shù)組會(huì)變。
數(shù)組的 push & pop 可以模擬常見(jiàn)數(shù)據(jù)結(jié)構(gòu)之一:棧。

const arr = [1, 2, 3]
const popVal = arr.pop()
console.log(popVal) // 3
console.log(arr) // [1, 2]

// 數(shù)組模擬常見(jiàn)數(shù)據(jù)結(jié)構(gòu)之一:棧
const stack = [0, 1]
stack.push(2) // 壓棧
console.log(stack) // [0, 1, 2]

const popValue = stack.pop() // 出棧
console.log(popValue) // 2
console.log(stack) // [0, 1]

3.unshift()

頭部壓入數(shù)據(jù),類(lèi)似于入隊(duì),原數(shù)組會(huì)變。

const arr = [1, 2, 3]
arr.unshift(0)
console.log(arr) // [0, 1, 2, 3]

4.shift()

頭部彈出數(shù)據(jù),原數(shù)組會(huì)變。
數(shù)組的 push(入隊(duì)) & shift(出隊(duì)) 可以模擬常見(jiàn)數(shù)據(jù)結(jié)構(gòu)之一:隊(duì)列。頭出尾入

const arr = [1, 2, 3]
const shiftVal = arr.shift()
console.log(shiftVal) // 1
console.log(arr) // [2, 3]

// 數(shù)組模擬常見(jiàn)數(shù)據(jù)結(jié)構(gòu)之一:隊(duì)列
const queue = [0, 1]
queue.push(2) // 入隊(duì)
console.log(queue) // [0, 1, 2]

const shiftValue = queue.shift() // 出隊(duì)
console.log(shiftValue) // 0
console.log(queue) // [1, 2]

5.concat()

concat會(huì)在當(dāng)前數(shù)組尾部拼接傳入的數(shù)組,然后返回一個(gè)新數(shù)組,原數(shù)組不變。

const arr = [1, 2, 3]
const arr2 = arr.concat([7, 8, 9])
console.log(arr) // [1, 2, 3]
console.log(arr2) // [1, 2, 3, 7, 8, 9]

6.indexOf()

在數(shù)組中尋找該值,找到則返回其下標(biāo),找不到則返回-1

const arr = [1, 2, 3]
console.log(arr.indexOf(2)) // 1
console.log(arr.indexOf(0)) // -1

7.includes()

數(shù)組查找,在數(shù)組中尋找該值,找到則返回true,找不到則返回false。

const arr = [1, 2, 3]
console.log(arr.includes(2)) // true
console.log(arr.includes(4)) // false

8.join()

數(shù)組分割成字符串,并返回該字符串,傳入什么參數(shù)則代表使用此參數(shù)作為分割符,不傳值則默認(rèn)逗號(hào)隔開(kāi),原數(shù)組不變。

const arr = [1, 2, 3]
console.log(arr.join()) // ‘1, 2, 3’
console.log(arr) // [1, 2, 3]

9.reverse()

翻轉(zhuǎn)原數(shù)組,并返回已完成翻轉(zhuǎn)的數(shù)組,原數(shù)組改變。

const arr = [1, 2, 3]
console.log(arr.reverse()) // [3, 2, 1]
console.log(arr) // [3, 2, 1]

10.slice(start,end)

start 開(kāi)始截取end,但是不包括end

const arr = [1, 2, 3, 4, 5]
console.log(arr.slice(1, 4)) // [2, 3, 4]
console.log(arr) // [1, 2, 3, 4, 5]

11.splice(start, deleteCount, item1, item2……)

用于添加、刪除、替換數(shù)組中的元素

  • start參數(shù) 開(kāi)始的位置
  • deleteCount要截取的個(gè)數(shù)
  • 后面的items為要添加的元素

如果deleteCount0,則表示不刪除元素,從start位置開(kāi)始添加后面的幾個(gè)元素到原始的數(shù)組里面。

返回值為由被刪除的元素組成的一個(gè)數(shù)組。
如果只刪除了一個(gè)元素,則返回只包含一個(gè)元素的數(shù)組。
如果沒(méi)有刪除元素,則返回空數(shù)組。

這個(gè)方法會(huì)改變?cè)紨?shù)組,數(shù)組的長(zhǎng)度會(huì)發(fā)生變化

const arr3 = [1, 2, 3, 4, 5, 6, 7, "f1", "f2"];
const arr4 = arr3.splice(2, 3) // 刪除第三個(gè)元素以后的三個(gè)數(shù)組元素(包含第三個(gè)元素)
console.log(arr4); // [3, 4, 5];
console.log(arr3); // [1, 2, 6, 7, "f1", "f2"]; 原始數(shù)組被改變

const arr5 = arr3.splice(2, 0, "wu", "leon"); 
// 從第2位開(kāi)始刪除0個(gè)元素,插入"wu","leon"
console.log(arr5); // [] 返回空數(shù)組
console.log(arr3); // [1, 2, "wu", "leon", 6, 7, "f1", "f2"]; 原始數(shù)組被改變

const arr6 = arr3.splice(2, 3, "xiao", "long");
// 從第 2 位開(kāi)始刪除 3 個(gè)元素,插入"xiao", "long"
console.log(arr6); // ["wu", "leon", 6]
console.log(arr3); //[ 1, 2, "xiao", "long", 7, "f1", "f2"]

const arr7 = arr3.splice(2); // 從第三個(gè)元素開(kāi)始刪除所有的元素
console.log(arr7);// ["xiao", "long", 7, "f1", "f2"]
console.log(arr3); // [1, 2]

12.sort()

  • 對(duì)數(shù)組的元素進(jìn)行排序,并返回?cái)?shù)組。
  • 默認(rèn)排序順序是在將元素轉(zhuǎn)換為字符串,然后比較它們的UTF-16代碼單元值序列時(shí)構(gòu)建的。
  • 由于它取決于具體實(shí)現(xiàn),因此無(wú)法保證排序的時(shí)間和空間復(fù)雜性。 可參考 MDN:Sort
const arr = [1, 2, 3]
arr.sort((a, b) => b - a)
console.log(arr) // [3, 2, 1]

13.toString()

將數(shù)組轉(zhuǎn)化成字符串,并返回該字符串,逗號(hào)隔開(kāi),原數(shù)組不變。

const arr = [1, 2, 3, 4, 5]
console.log(arr.toString()) // ‘1, 2, 3, 4, 5’
console.log(arr) // [1, 2, 3, 4, 5]



二、字符串常用方法

1.charAt()

返回指定索引位置處的字符
類(lèi)似于數(shù)組用中括號(hào)獲取相應(yīng)下標(biāo)位置的數(shù)據(jù)。

var str = 'abcdefg'
console.log(str.charAt(2)) // 輸出 'c' 
console.log(str[2]) // 輸出 'c'

2.concat()

類(lèi)似數(shù)組的concat(),用來(lái)返回一個(gè)合并拼接兩個(gè)或兩個(gè)以上字符串。原字符串不變。

const str1 = 'abcdefg'
const str2 = '1234567'
const str3 = str1.concat(str2)
console.log(str3) // 輸出 'abcdefg1234567'

3.indexOf()、lastIndexOf()

indexOf,返回一個(gè)字符在字符串中首次出現(xiàn)的位置
lastIndexOf返回一個(gè)字符在字符串中最后一次出現(xiàn)的位置。

const str = 'abcdcefcg'
console.log(str.indexOf('c')) // 輸出 '2'
console.log(str.lastIndexOf('c')) // 輸出 '7'

4.slice()

提取字符串的片斷,并把提取的字符串作為新的字符串返回出來(lái)。原字符串不變。

const str = 'abcdefg'
console.log(str.slice()) // 輸出 'abcdefg', 不傳遞參數(shù)默認(rèn)復(fù)制整個(gè)字符串
console.log(str.slice(1)) // 輸出 'bcdefg',傳遞一個(gè),則為提取的起點(diǎn),然后到字符串結(jié)尾
console.log(str.slice(2, str.length-1)) // 輸出'cdef',傳遞兩個(gè),為提取的起始點(diǎn)和結(jié)束點(diǎn)

5.split()

使用指定的分隔符將一個(gè)字符串拆分為多個(gè)子字符串?dāng)?shù)組并返回,原字符串不變。

const str = 'A*B*C*D*E*F*G'
console.log(str.split('*')) // 輸出 ["A", "B", "C", "D", "E", "F", "G"]

6.substr(), substring()

這兩個(gè)方法的功能都是截取一個(gè)字符串的片段,并返回截取的字符串。

  • substrsubstring這兩個(gè)方法不同的地方就在于參數(shù)二,substr的參數(shù)二是截取返回出來(lái)的這個(gè)字符串指定的長(zhǎng)度,substring的參數(shù)二是截取返回這個(gè)字符串的結(jié)束點(diǎn),并且不包含這個(gè)結(jié)束點(diǎn)。
  • 而它們的參數(shù)一,都是一樣的功能,截取的起始位置。
  • substr()并非JavaScript核心語(yǔ)言的一部分,未來(lái)將可能會(huì)被移除掉。如果可以的話(huà),使用 substring() 替代它

注意事項(xiàng)substr的參數(shù)二如果為0或者負(fù)數(shù),則返回一個(gè)空字符串,如果未填入,則會(huì)截取到字符串的結(jié)尾去。substring的參數(shù)一和參數(shù)二為NAN或者負(fù)數(shù),那么它將被替換為0。

const str = 'ABCDEFGHIJKLMN'
console.log(str.substr(2))  // 輸出 'CDEFGHIJKLMN'
console.log(str.substring(2)) // 輸出 'CDEFGHIJKLMN'

console.log(str.substr(2, 9))  // 輸出 'CDEFGHIJK'
console.log(str.substring(2, 9))  // 輸出 'CDEFGHI'

7.match()

match()方法可在字符串內(nèi)檢索指定的值,或找到一個(gè)或多個(gè)正則表達(dá)式的匹配,并返回一個(gè)包含該搜索結(jié)果的數(shù)組。

const str = '2018年結(jié)束了,2019年開(kāi)始了,2020年就也不遠(yuǎn)了'
const reg = /\d+/g  // 這里是定義匹配規(guī)則,匹配字符串里的1到多個(gè)數(shù)字
console.log(str.match(reg))  // 輸出符合匹配規(guī)則的內(nèi)容,以數(shù)組形式返回 ['2018', '2019', '2020']
console.log(str.match('20'))  // 不使用正則 ["20", index: 0, input: "2018年結(jié)束了,2019年開(kāi)始了"]

注意事項(xiàng):如果match方法沒(méi)有找到匹配,將返回null。
如果找到匹配,則 match方法會(huì)把匹配到以數(shù)組形式返回
如果正則規(guī)則未設(shè)置全局修飾符g,則 match方法返回的數(shù)組有兩個(gè)特性:inputindex。input屬性包含整個(gè)被搜索的字符串。index屬性包含了在整個(gè)被搜索字符串中匹配的子字符串的位置。

8.replace()

replace 查找并替換,接收兩個(gè)參數(shù),參數(shù)一是需要替換掉的字符或者一個(gè)正則的匹配規(guī)則,參數(shù)二,需要替換進(jìn)去的字符,在實(shí)際的原理當(dāng)中,參數(shù)二,你可以換成一個(gè)回調(diào)函數(shù)。

const str = '2018年結(jié)束了,2019年開(kāi)始了,2020年就也不遠(yuǎn)了'
const rex = /\d+/g  // 這里是定義匹配規(guī)則,匹配字符串里的1到多個(gè)數(shù)字
const str1 = str.replace(rex, '****') 
console.log(str1) // 輸出:"****年結(jié)束了,****年開(kāi)始了,****年也不遠(yuǎn)了"
const str2 = str.replace(rex, function(item){
  console.log(arguments)  // 看下面的圖片
  const arr = ['零', '壹', '貳', '叁', '肆', '伍', '陸', '柒', '捌', '玖']
  let newStr = ''
  item.split('').map(function(i){
    newStr += arr[i]
  })                    
  return newStr       
})
console.log(str2) // 輸出:貳零壹捌年結(jié)束了,貳零壹玖年開(kāi)始了,貳零貳零年也不遠(yuǎn)了

9.search()

檢索字符串中指定的子字符串,在目標(biāo)字符串中搜索與正則規(guī)則相匹配的字符,搜索到,則返回第一個(gè)匹配項(xiàng)在目標(biāo)字符串當(dāng)中的位置,沒(méi)有搜索到則返回一個(gè)-1。

const str = '2018年結(jié)束了,2019年開(kāi)始了,2020年就也不遠(yuǎn)了'
const reg = /\d+/i  // 這里是定義匹配規(guī)則,匹配字符串里的1到多個(gè)數(shù)字
console.log(str.search(reg)) // 輸出 0  這里搜索到的第一項(xiàng)是從位置0開(kāi)始的

10.toLowerCase(),toUpperCase()

toLowerCase字母轉(zhuǎn)換成小寫(xiě),
toUpperCase()字母轉(zhuǎn)換成大寫(xiě)

const str1 = 'abcdefg'
const str2 = 'ABCDEFG'
console.log(str2.toLowerCase())  // 輸出:'abcdefg'
console.log(str1.toUpperCase())  // 輸出:'ABCDEFG'

11.includes(), startsWith(), endsWith()

includes、startsWith、endsWith,屬于es6的新增方法
includes 用來(lái)檢測(cè)目標(biāo)字符串對(duì)象是否包含某個(gè)字符,返回一個(gè)布爾值,
startsWith用來(lái)檢測(cè)當(dāng)前字符是否是目標(biāo)字符串的起始部分
endwith相對(duì)的是用來(lái)檢測(cè)是否是目標(biāo)字符串的結(jié)尾部分

const str = 'Excuse me, how do I get to park road?'
console.log(str.includes('how')) // 輸出:true
console.log(str.startsWith('Excuse')) // 輸出: true
console.log(str.endsWith('?')) // 輸出: true

12.repeat()

將原字符串重復(fù)n次,返回一個(gè)新的字符串對(duì)象,新字符串等于重復(fù)了指定次數(shù)的原始字符串。接收一個(gè)參數(shù),就是指定重復(fù)的次數(shù)。原字符串不變。

const str = 'http'
const str2 = str.repeat(3)
console.log(str) // 輸出:'http'
console.log(str2) // 輸出:'httphttphttp'



三、常用遍歷方法&高階函數(shù)

1.for()

最常用的for循環(huán),經(jīng)常用的數(shù)組遍歷,也可以遍歷字符串。

const arr = [1, 2, 3]
const str = 'abc'
for (let i = 0; i < arr.length; i++) {
  console.log(arr[i])
  console.log(str[i])
}

2.while() / do while()

while、do while主要的功能是,當(dāng)滿(mǎn)足while后邊所跟的條件時(shí),來(lái)執(zhí)行相關(guān)業(yè)務(wù)。

區(qū)別:

  • while會(huì)先判斷是否滿(mǎn)足條件,然后再去執(zhí)行花括號(hào)里面的任務(wù)
  • do while則是先執(zhí)行一次花括號(hào)中的任務(wù),再去執(zhí)行while條件,判斷下次還是否再去執(zhí)行do里面的操作。也就是說(shuō) do while至少會(huì)執(zhí)行一次操作.
while(條件){
  執(zhí)行...
}
------------
do{
  執(zhí)行...
}
while(條件)

3.forEach()

拷貝一份遍歷原數(shù)組。

  • return無(wú)法終止循環(huán)。不過(guò)可以起到continue效果。
  • 本身是不支持的continuebreak語(yǔ)句的我們可以通過(guò)someevery來(lái)實(shí)現(xiàn)。
const arr = [5,1,3,7,4]
arr.forEach((item, index) => {
  if (item < 2) return
  console.log(`索引:${index},數(shù)值:${item}`)
  arr[5] = 0
})
console.log(arr)
// 打印結(jié)果:
// 索引:0,數(shù)值:5
// 索引:2,數(shù)值:3
// 索引:3,數(shù)值:7
// 索引:4,數(shù)值:4
// [5, 1, 3, 7, 4, 0]

4.for…in

  • for...in 是 ES5 標(biāo)準(zhǔn), 此方法遍歷數(shù)組效率低,主要是用來(lái)循環(huán)遍歷對(duì)象的屬性。
  • 遍歷數(shù)組的缺點(diǎn):數(shù)組的下標(biāo)index值是數(shù)字,for-in遍歷的index"0","1","2"等是字符串。
  • Object.defineProperty,建立的屬性,默認(rèn)不可枚舉。
const foo = {
  name: 'bar',
  sex: 'male'
}
Object.defineProperty(foo, "age", { value : 18 })
for(const key in foo){
  console.log(`可枚舉屬性:${key}`)
}
console.log(`age屬性:${foo.age}`)
// 打印結(jié)果:
// 可枚舉屬性:name
// 可枚舉屬性:sex
// age屬性:18

5.for…of

for…ofES6新增的方法,但是for…of不能去遍歷普通的對(duì)象,for…of的好處是可以使用break跳出循環(huán)。

  • for-of這個(gè)方法避開(kāi)了for-in循環(huán)的所有缺陷
  • forEach()不同的是,它可以正確響應(yīng)breakcontinuereturn語(yǔ)句
  • for-of循環(huán)不僅支持?jǐn)?shù)組,還支持大多數(shù)類(lèi)數(shù)組對(duì)象,例如DOM NodeList對(duì)象
  • for-of循環(huán)也支持字符串遍歷
// for of 循環(huán)直接得到的就是值
const arr = [1, 2, 3]
for (const value of arr) {
 console.log(value)
}

面試官:說(shuō)一下 for...infor...of 區(qū)別?

(1)for…in 用于可枚舉數(shù)據(jù),如對(duì)象、數(shù)組、字符串
(2)for…of 用于可迭代數(shù)據(jù),如數(shù)組、字符串、Map、Set

6.every / some

返回一個(gè)布爾值。當(dāng)我們需要判定數(shù)組中的元素是否都滿(mǎn)足某些條件時(shí),可以使用every / some

區(qū)別:

  • every會(huì)去遍歷判斷是否數(shù)組中的每一項(xiàng)都滿(mǎn)足條件,遇到不滿(mǎn)足的直接停止遍歷返回false(只要有一個(gè)是false,便返回false),
  • some則是當(dāng)某一項(xiàng)滿(mǎn)足條件時(shí)停止遍歷,返回true(只要有一個(gè)是true,便返回true)。
// every
const foo = [5,1,3,7,4].every((item, index) => {
  console.log(`索引:${index},數(shù)值:${item}`)
  return item > 2
})
console.log(foo)
// every 打?。?// 索引:0,數(shù)值:5
// 索引:1,數(shù)值:1
// false

// some
const foo = [5,1,3,7,4].some((item, index) => {
  console.log(`索引:${index},數(shù)值:${item}`)
  return item > 2
})
console.log(foo)
// some 打?。?// 索引:0,數(shù)值:5
// true

7.filter()

  • filter方法用于過(guò)濾數(shù)組成員,滿(mǎn)足條件的成員組成一個(gè)新數(shù)組返回。
  • 它的參數(shù)是一個(gè)函數(shù),所有數(shù)組成員依次執(zhí)行該函數(shù),返回結(jié)果為true的成員組成一個(gè)新數(shù)組返回。
  • 該方法不會(huì)改變?cè)瓟?shù)組。
const foo = [5,1,3,7,4].filter((item,index) => {
  console.log(`索引:${index},數(shù)值:${item}`)
  return item > 2
})
console.log(foo)
// 打印結(jié)果:
// 索引:0,數(shù)值:5
// 索引:1,數(shù)值:1
// 索引:2,數(shù)值:3
// 索引:3,數(shù)值:7
// 索引:4,數(shù)值:4
// [5, 3, 7, 4]

8.map()

  • map即是 “映射”的意思 ,原數(shù)組被“映射”成對(duì)應(yīng)新數(shù)組。
  • map:支持return,相當(dāng)與原數(shù)組克隆了一份,把克隆的每項(xiàng)改變了,也不影響原數(shù)組。
const foo = [5,1,3,7,4].map((item,index) => {
  console.log(`索引:${index},數(shù)值:${item}`)
  return item + 2
})
console.log(foo)
// 打印結(jié)果:
// 索引:0,數(shù)值:5
// 索引:1,數(shù)值:1
// 索引:2,數(shù)值:3
// 索引:3,數(shù)值:7
// 索引:4,數(shù)值:4
// [7, 3, 5, 9, 6]

9. reduce() / reduceRight()

reduce從左到右將數(shù)組元素做“疊加”處理(從第一個(gè)成員到最后一個(gè)成員),返回一個(gè)值。
reduceRight 從右到左(從最后一個(gè)成員到第一個(gè)成員)。

const foo = [5,1,3,7,4].reduce((total, cur) => {
  console.log(`疊加:${total},當(dāng)前:${cur}`)
  return total + cur
})
console.log(foo)
// 打印結(jié)果:
// 疊加:5,當(dāng)前:1
// 疊加:6,當(dāng)前:3
// 疊加:9,當(dāng)前:7
// 疊加:16,當(dāng)前:4
// 20

10.Object.keys遍歷對(duì)象的屬性

Object.keys方法的參數(shù)是一個(gè)對(duì)象,返回一個(gè)數(shù)組。
該數(shù)組的成員都是該對(duì)象自身的(而不是繼承的)所有屬性名,且只返回可枚舉的屬性。

const obj = {
  p1: 123,
  p2: 456
};
Object.keys(obj) // ["p1", "p2"]

11.Object.getOwnPropertyNames() 遍歷對(duì)象的屬性

Object.getOwnPropertyNames方法與Object.keys類(lèi)似,也是接受一個(gè)對(duì)象作為參數(shù),返回一個(gè)數(shù)組,包含了該對(duì)象自身的所有屬性名。但它能返回不可枚舉的屬性。

const arr = ['Hello', 'World'];
Object.keys(arr) // ["0", "1"]
Object.getOwnPropertyNames(arr) // ["0", "1", "length"]

以上遍歷方法的區(qū)別:

  • map()和filter()都會(huì)跳過(guò)空位,for 和 while 不會(huì)

Object.keys 與 Object.getOwnPropertyNames

  • 相同點(diǎn):都是遍歷對(duì)象的屬性,也是接受一個(gè)對(duì)象作為參數(shù),返回一個(gè)數(shù)組,包含了該對(duì)象自身的所有屬性名。
  • 不同點(diǎn):Object.keys不能返回不可枚舉的屬性;Object.getOwnPropertyNames能返回不可枚舉的屬性。

map(),forEach(),filter()循環(huán)的相同點(diǎn)與不同點(diǎn)

相同點(diǎn):

  • forEach,map,filter循環(huán)中途是無(wú)法停止的,總是會(huì)將所有成員遍歷完。
  • 他們都可以接受第二個(gè)參數(shù),用來(lái)綁定回調(diào)函數(shù)內(nèi)部的this變量,將回調(diào)函數(shù)內(nèi)部的this對(duì)象,指向第二個(gè)參數(shù),間接操作這個(gè)參數(shù)(一般是數(shù)組)

不同點(diǎn):

  • forEach循環(huán)沒(méi)有返回值
  • map,filter循環(huán)有返回值
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 一、Array數(shù)組方法 本質(zhì)上,數(shù)組屬于一種特殊的對(duì)象。typeof運(yùn)算符會(huì)返回?cái)?shù)組的類(lèi)型是object。由于數(shù)組...
    kevision閱讀 576評(píng)論 0 0
  • Js數(shù)組常用的方法1、Push方法。arr.push(數(shù)值)。在數(shù)組尾部插入一個(gè)或者多個(gè)新元素、可以返回一個(gè)數(shù)組的...
    78e96b7bacb3閱讀 110評(píng)論 0 0
  • sort() 數(shù)組排序 (改變?cè)瓟?shù)組) 參數(shù)為規(guī)定排序的比較函數(shù)(非必填) copyWithin() 數(shù)組的指定位...
    阿克蘭閱讀 330評(píng)論 0 0
  • 本文目錄: 1.手寫(xiě)reduce 2.手寫(xiě)map 3.手寫(xiě)filter 4.手寫(xiě)防抖 5.手寫(xiě)節(jié)流 6.實(shí)現(xiàn)fla...
    前端輝羽閱讀 390評(píng)論 0 8
  • 1、string charAt(index):返回指定位置的字符。 concat(str1,str2,...):用...
    刀鋒_3e95閱讀 295評(píng)論 0 1

友情鏈接更多精彩內(nèi)容