当前位置:网站首页>ES6 other syntax and extended syntax summary
ES6 other syntax and extended syntax summary
2022-07-23 22:53:00 【Bald mule】
Catalog
3、 ... and 、flat Array dimension reduction
Four 、flat and map A combination of
5、 ... and 、 Object extension method
6、 ... and 、 fromEntries Put the form of key value pairs Turn to object
7、 ... and 、trim Remove the space
8、 ... and 、?. The object level is deep
One 、includes
Used to detect whether the array contains an element , Returns a Boolean value .
example : Judge 2 Whether in arr Array Just go back to true Instead of false.
let arr = [1,2,3];
console.log(arr.includes(2));
Two 、** Power operation
stay ES7 Introducing the exponential operator **, Used to implement power operation , Function and Math.pow The result is the same .
example :
console.log(10**3);//10*10*10
3、 ... and 、flat Array dimension reduction
let arr = [1,[[2],3],4];
console.log(arr.flat(2)); // Default drop 1 dimension , Parameters : Specify dimensions 
Four 、flat and map A combination of
let arr = [1,2,3,4];
let newarr = arr.flatMap((item)=>{
return [item];
})
console.log(newarr);
5、 ... and 、 Object extension method
const Stu = {info:" Class information ",data:[" Zhang San "," Li Si "," Wang Wu "],major:" Computer science "};
console.log(Object.keys(Stu));// Get all the keys
console.log(Object.values(Stu));// Get all the value
const arrMap = Object.entries(Stu);// Turn the object into [[key,value],[],[]]
const myMap = new Map(arrMap);
console.log(myMap);
realname:{
value:" Zhang San ",
writable:true,// Property is writable
configurable:true,// Properties are not configurable , Delete
enumerable:true,// Enumerable or not
},
})
Person.realname = " Li Si ";
delete Person.realname;// Delete attribute
console.log(Person);
for(let key in Person){
console.log(key);
}6、 ... and 、 fromEntries Put the form of key value pairs Turn to object
let arr = [["realname"," Zhang San "],["age",19]];
const Person =Object.fromEntries(arr);
console.log(Person);![]()
7、 ... and 、trim Remove the space
let str = " abc ";
console.log(str);
console.log(str.trimStart() + "---");
console.log("---" + str.trimEnd()+"---")
console.log("---"+str.trim() + "---");8、 ... and 、?. The object level is deep
const Person = {
realname: " Zhang San ",
info: {
sex: " Gender ",
height: "180",
}
}
const height = Person?.xxx?.sex;
console.log(height);
边栏推荐
- DeFi项目的盈利逻辑 2021-04-26
- Stm32+esp8266+mqtt protocol connects Alibaba cloud Internet of things platform
- Introduction and project development of MVVM and mvvmlight (I)
- Microsoft SQL Server database language and function usage (XIII)
- 浅析基于NVR技术的视频能力与未来发展趋势
- 糖尿病遗传风险检测挑战赛Baseline
- DHCP: prevent rogue DHCP server in the network
- Utilisation des fonctions fléchées es6
- 1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
- Can Verilog of synthetizable be integrated
猜你喜欢

Linked list - 203. remove linked list elements

Profit logic of DFI project 2021-04-26
思源笔记的字体比其他的编辑器(Atom,VSC,sublime)内字体渲染更细更淡

海外资深玩家的投资建议(3) 2021-05-04

Tap series article 7 | easy to manage pipeline configuration

Investment suggestions for overseas senior players (3) 2021-05-04

SOLIDWORK learning notes: Sketch geometric relationships and editing

Series of articles | the way to advance the microservice architecture in the cloud native era - best practices of microservice splitting

Tools in the tools package of Damon database (operate Damon database)

1000个Okaleido Tiger首发上线Binance NFT,引发抢购热潮
随机推荐
D1-H 开发板——哪吒 开发入门
TAP 系列文章5 | 云原生构建服务
What else do entrepreneurs need besides money? Exclusive interview with Mingyue Lake venture capital institutions
[golang learning notes] concurrency basis
接口测试
视频号加强打击低俗内容:对违背公序良俗的内容必须赶尽杀绝
Getting started database days3
Excel password related
1000 okaleido tiger launched binance NFT, triggering a rush to buy
ES6箭頭函數的使用
Programming in the novel [serial 16] the moon bends in the yuan universe
Microsoft SQL Server database language and function usage (XIII)
Matlab小波工具箱导入信号出错(doesn‘t contain one dimensional Singal)
Array - 704. Binary search
"Morning reading" if you were in my position, what would you do? How do we do it,
TAP 系列文章6 | TAP的应用模型
How ZK solves the problem of cerebral fissure
记忆化搜索 - DP
At the forefront of the times, Huawei aims at the wind and sea of digital finance
Array -- 27. remove elements
