当前位置:网站首页>ES6 add -- > object
ES6 add -- > object
2022-07-28 07:02:00 【Hahaha~】
One 、 Object literal
- es6 Object members of can be written as a word This word is the variable name : Take the variable name as the attribute name of the object Value as attribute value ( Easy to read , Improve the development effect )
Short form of property :
var a = 100
var obj = {
age: 20,
a
} // Put the identifier a As the property name of the object hold a Take the value of as its attribute value Method shorthand :
var obj = {
say: function() {},
tool() {} // Abbreviation
}
var obj1={
name:"haha", // Commonly used writing
"age":21, // Standard writing
["hello"+10]:90, //es6 Writing
[false]:90, //es6 Writing
}notes :ES6 Allow expressions as property names , But be sure to put the expression in square brackets
The concise representation of an attribute and the expression of an attribute name cannot be used at the same time , Otherwise, an error will be reported
Two 、 Object's extension operator ...
- Extension operators (...) Used to extract all traversable properties of the parameter object and copy it to the current object
Merge two objects :
var obj = {
age: 21,
name: "1",
arr: [10, 20, 30]
}
var obj2 = {...obj}
console.log(obj, obj2)var obj={name:"lili"}
var obj2={age:21}
var obj3={...obj,...obj2,score:100}
console.log(obj3)3、 ... and 、 New static method of object
- Object.is(value1,value2): Used to compare whether two values are strictly equal Be similar to ===
a=Object.is(+0,-0)
console.log(a) //false +-0 It's not equal
b=Object.is(NaN,NaN)
console.log(b) //true NaN equal
// And === The difference between
// One is +0 It's not equal to -0
Object.is(+0,-0); //false
+0 === -0 //true
// Two is NaN Equal to itself
Object.is(NaN,NaN); //true
NaN === NaN //false边栏推荐
- Hdu-5805-nanoape loves sequence (thinking questions)
- Firewall - iptables firewall (four tables and five links, firewall configuration method, detailed explanation of matching rules)
- Principle and configuration of NAT and pat
- MOOC翁恺C语言 第四周:进一步的判断与循环:3.多路分支4.循环的例子5.判断和循环常见的错误
- Technology sharing | do you know the functions of the server interface automated testing and requests library?
- Hdu-1097-a hard puzzle (fast power)
- What's a good gift for Tanabata? Niche and advanced product gift recommendation
- 小tips
- 1、 PXE overview and installation
- shell脚本——编程条件语句(条件测试、if语句、case分支语句、echo用法、for循环、while循环)
猜你喜欢

Which brand of air conduction earphones is good and highly praised

DNS domain name resolution service

NFS shared storage service

What is the most practical gift for Tanabata? A gift that will never go wrong is worth buying

JSON notes

SSH服务配置

Esxi community nvme driver update v1.1

CentOS7部署MySQL数据库服务器

What kind of air conduction Bluetooth headset with good configuration is recommended

Custom component -- communication between parent and child components
随机推荐
HDU-5805-NanoApe Loves Sequence(思维题)
Archery database audit platform deployment
[learning notes] drive
Technology sharing | do you know the functions of the server interface automated testing and requests library?
Method of designing test cases
Which brand of air conduction earphones is better? These four should not be missed
小甲鱼C(第六章数组1、2)
Use powercli to create a custom esxi ISO image
Custom components -- slots
搭建PHP7私有仓库
LNMP搭建过程详解
cocos2d-x 学习笔记——瓦片地图TiledMap
MySQL主主
Custom component -- pure data field & component life cycle
It is recommended to wear air conduction earphones, which do not need to wear in ear
Cocos2d-x learning notes Tile Map tiledmap
MOOC翁恺 C语言 第三周:判断与循环:1.判断
Results fill in the blank. How many days of national day are Sundays (solved by pure Excel)
Result number of filled briquettes
Applet custom components - data, methods, and properties