当前位置:网站首页>ES6 from getting started to mastering 09: symbol type
ES6 from getting started to mastering 09: symbol type
2022-07-28 03:36:00 【Kai Xiaomo】
explain
ES6 From entry to Mastery Series ( whole 23 speak ) Learning notes .
Symbol type
Raw data type :Symbol, It represents a unique value .
The greatest use : Private variables used to define objects .
const kaimo = Symbol("kaimo");
const kaimo2 = Symbol("kaimo");
console.log(kaimo === kaimo2);

If you use Symbol Variables in defined objects , When taking values, you must use [ Variable name ].
let s = Symbol('s');
console.log(s);
let obj = {
[s]: "kaimo"
}
console.log(obj[s]);

Be careful : use Symbol Variables in defined objects cannot be for in Go through it
let s = Symbol('s');
let obj = {
[s]: "kaimo",
ss: "kaimo2"
}
for(let key in obj) {
console.log(key)
}

You should use Object.getOwnPropertySymbols perhaps Reflect.ownKeys To deal with .
let s = Symbol('s');
let obj = {
[s]: "kaimo",
ss: "kaimo2"
}
console.log(Object.keys(obj))
console.log("--------------")
console.log(Object.getOwnPropertySymbols(obj))
console.log("--------------")
console.log(Reflect.ownKeys(obj))

边栏推荐
- 整合SSM实现增删改查搜索
- 203. Remove linked list elements
- 收藏|0 基础开源数据可视化平台 FlyFish 大屏开发指南
- 如何让外网访问内网IP(esp8266网页使用)
- 容器相关的概念
- 4-day excel practical training camp, 0.01 yuan special offer for only three days, 200 sets of learning kits
- How to use JDBC to operate database
- Light year admin background management system template
- 动态内存管理中的malloc、free、calloc、realloc动态内存开辟函数
- ES6 从入门到精通 # 09:Symbol 类型
猜你喜欢

How to solve the problem of win11 black desktop background?

How to uninstall clean ZABBIX service? (super detailed)

Outlook tutorial, how to use color categories and reminders in outlook?

Integrate SSM to realize search of addition, deletion, modification and query

Analysis of redis network model

每日练习------实现双色球的彩票功能。规则:从36个红球中随机选择不重复的6个数,从15个篮球中随机选择1个组成一注彩票。可以选择买多注。

max_ pool2d(): argument ‘input‘ (position 1) must be Tensor, not NoneType

MySQL stored procedures use cursors to synchronize data between two tables

C language to achieve a dynamic version of the address book

Responsive high-end website template source code Gallery material resource download platform source code
随机推荐
Win11 how to rename an audio device
MySQL的碎片有哪些
动态规划——1049. 最后一块石头的重量 II
IronOCR for .NET 2022.8
How to solve the problem of win11 black desktop background?
Redis memory recycling
Mouse operation and response
ES6 从入门到精通 # 09:Symbol 类型
如何解决mysql深分页问题
4-day excel practical training camp, 0.01 yuan special offer for only three days, 200 sets of learning kits
20220727 use the Bluetooth module hc-05 of Huicheng technology to pair mobile phones for Bluetooth serial port demonstration
Redis communication protocol -- resp protocol
An article grasps the calculation and processing of date data in PostgreSQL
沃尔沃:深入人心的“安全感” 究竟靠的是什么?
[错题]Concatenation
Collection | 0 basic open source data visualization platform flyfish large screen development guide
LabVIEW加载和使用树型控件项目中的定制符号
203. Remove linked list elements
机器人开发--丝杠与导轨
Summary of concurrent programming interview questions