ES6と拡張子の配列の値を拡張

簡単に復習するための簡単な記録。

:数値拡張@ 
はconsole.log(//有限の整数、非デジタル決定
Number.isFinite(10)、
Number.isInteger(12)と、
Number.isInteger(12.1)、
Number.isNaN(のNaN 3)、
Number.isNaN (10) 
はconsole.log(//分析正、負、0 
  Math.sign(2)、
  Math.sign(0)、
  Math.sign(-1)、
  Math.sign( '2')、// 1 
  Math.sign( 'ABC')//のNaN 3 
はconsole.log(//取得小数整数部分
  Math.trunc(1.2)、
  Math.trunc(4.2)。4 // 

//配列が延びる
にconsole.log(
  配列.of(1,2,3,4)、// [1,2 ,. 3 ,. 4] 
  Array.of()// [] 
  Array.from( 'A')、配列//にセット 
  アレイ。 ( "HTTP1、HTTP2、http3から "、アイテム=> item.split( ''))、
  アレイ。 ([1,2,3]、(アイテム )=>項目* 2)// 2つのパラメータを受け付け、配列関数マップ操作
console.log(
  [1,2、不定] .fill(7)、// [7,7,7]全部替换
  [ '、 'B'、 'C'、 'D'、 'E']。フィル(1,0,3)、//把从0位置到3位置元素、替换为1 
  [1,2,3,4,5,6,7,8] .fill(0,1,2) 

{//キー、値、エントリ
  ([ 'C'、 ''、 'B']でIDXましょう。キー()){ため
    にconsole.log( 'IDX'、IDX)
  } 
  ため(LET値[」 A」、 'B'、 'C']の値()){ 
    にconsole.log( ''、値)値
  } 
  '、 'B [における[インデックスをせ(ため、値]'、 'C'] .entries()){ 
    にconsole.log( `度:$ {索引}、値:$ {値} ')
  } 
} 

{ 
  // findIndexを含む検索 
  にconsole.log([1,2,3,4] .find(項目=>アイテム> 2))を
  にconsole.log([1,2,3,4]。findIndex(項目=>アイテム> 2)) 
  はconsole.log([1,2,3,4] .INCLUDES(2)) 
  をtrueにはconsole.log([1,2,3、のNaN 3] .INCLUDES(のNaN 3))// 
} 

{ 
  //あるいはインデックス0の要素は、インデックスは、インデックス間の素子3に2(2を含む)を置き換えるために使用される
  にconsole.log([1,2,3「」 ]。copyWithin(0 、2,3))// [3,2,3、 'A'] 
}

  

おすすめ

転載: www.cnblogs.com/lk-food/p/12111306.html