当前位置:网站首页>ES6 -- object
ES6 -- object
2022-07-16 05:54:00 【Like to drink pearl milk tea】
Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
List of articles
Catalog
1. Concise representation of object attributes
2. Shorthand for object methods
1. Concise representation of object attributes
var count=20
var obj={count} //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 is taken as the attribute value ( Easy to read , Improve the development effect )
var {age}={age:20}
console.log(obj["count"]) var obj={count:count} <==> {"count":count} // Two ways to write object members , Equal writing
Running results :

2. Shorthand for object methods
Method shorthand : Functions have many nicknames according to business : Constructors Static functions Method Event handler ( Monitor ) Closure Callback function Hook function
var obj = {
name: "karen",
say: function() { }
}
//name and say All are obj Object members name yes obj Properties of (pro) say It's the object obj Methods
var obj2 = {
name: "jack",
say() { } //say(){ } Method shorthand , And the above say: function() { } equal
}
3. The attribute expression of an object
var obj = {
name: "karen", // Commonly used writing
"age":20, // Standard writing ,
["hello"+100]:90, //es6 How to write it
[false]:90, //es6 How to write it
[{life:100}]:90, //es6 How to write it ,
[Symbol(100)]:200
}
console.log(obj)Running results :

When two objects have the same properties , Those with the same name will be overwritten , The back one will cover the front one .
Extension operators (...) Used to extract all traversable properties of the parameter object and copy it to the current object
var obj={name:"karen",age:20,arr:[10,20],life:2}
var obj3={life:7,x:100}
var obj2={life:80,...obj,life:100,...obj3}
console.log(obj2)
console.log(obj2,obj==obj2,obj.arr==obj2.arr)Running results :

4. New methods of object
Object.is(value1, value2): Used to compare whether two values are strictly equal , And (===) similar .
var a=-0
var b=+0
var re=Object.is(a,b) // Namely === Made a little adjustment
console.log(re,a===b)
var re=(["10"]==10)
console.log(re) Running results :
边栏推荐
- For some problems encountered in using crontab, errors are reported /var/spool/cron: permission denied and bash: /usr/bin/chattr: permission denied
- [NCTF2019]Fake XML cookbook
- 36.js-- prototype chain 2-- (mainly written test questions)
- PLSQL problem solving ora-12154: tns: unable to resolve the specified connection identifier
- admin 系统被嵌套在第三方系统中的跨域异常
- Network security emergency response terminal detection and response technology
- Image source configuration of electron and electron Builder (2022-06)
- Flag under buuctf mask
- Intranet penetration notes - vulnhub intranet course completion penetration
- 文件上传-解析漏洞
猜你喜欢

Network security emergency response - electronic data forensics technology

BUUCTF 来首歌吧
![[Huang ah code] wechat applet +php realizes instant messaging chat function](/img/c4/d571f10588b7b4679105f9552bb727.png)
[Huang ah code] wechat applet +php realizes instant messaging chat function

WP of the southwest division of the 15th National College Students Information Security Competition (ciscn) 2022

Buuctf backdoor killing

Test MySQL master-slave synchronization under win10

JS scope and scope chain
![[Huang ah code] today, someone actually asked me: what does where 1=1 mean?](/img/66/2413c1cfb39e6384dc2fa8af276e9e.png)
[Huang ah code] today, someone actually asked me: what does where 1=1 mean?

暑期沉淀web学习——php基础

Collect form data
随机推荐
操作系统笔记——Windows应急响应和安全加固
Automated machine learning
Intranet penetration notes --:) a smiling face
内网渗透笔记——msf
Tree structure tool -treeutil use
PHP docking Alipay web payment -tp5.1 framework
[Huang ah code] getting started with MySQL - 1. SQL execution process
Mobile web development
淘宝项目练习总结
handsontable pro 授权码 key 生成器(JS函数)(仅供学习交流)
window系统盘瘦身(开发)
Handsontable Pro authorization code key generator (JS function) (for learning and communication only)
Steps for JS parsing engine to execute JS code
移动web开发
[2021] node连接oracle数据库示例[使用oracle官方组件]
[Huang ah code] redis realizes fuzzy query and deletes | redis obtains the key according to the prefix
Svelte official introductory tutorial (4) -- template logic
40.js -- the same name identifier promotion problem
Test MySQL master-slave synchronization under win10
Intranet penetration notes - Registry self startup and MSI rights lifting