WEBフロントエンド2020アップデートユーティリティのコードセクション(継続的に更新)

解体のGET JSONデータを使用して1、

let jsonData = {
id: 1,
status: "OK",
data: [a, b]
};
let { id, status, data: number } = jsonData;
console.log(id, status, number ); // 1,“OK”,[a, b]

図2に示すように、アレイ内の拡張文字列を使用して

let a1 = [1,2];
let a2 = [3,4];
console.log([...a1,...a2]) // [1,2,3,4]

3、体重セットを達成するために、配列を使用して

let arr = [1,2,2,3];
console.log([... new Set(arr)]) // [1,2,3]

図4に示すように、この限り変化を指します

let name = "maomin";
let obj = {
  name:'xqm',
  say:function(year,place){
  	console.log(this.name+' is '+year+' born from '+place);
  }
};
let say = obj.say;
setTimeout(function(){
	say.apply(obj,['1996','China']);
},0)

5、解体迅速交換変数値を使用して

let a = 10;
let b = 20;
[a,b] = [b,a];

図6に示すように、多変数割当解体を使用

let [a,b,c]=[1,2,3];
公開された163元の記事 ウォンの賞賛288 ビュー179万+

おすすめ

転載: blog.csdn.net/qq_39045645/article/details/104089659