当前位置:网站首页>ES6-新增的基本数据:Symbol
ES6-新增的基本数据:Symbol
2022-07-31 05:18:00 【春意迟迟、】
es5中基本数据: null undefined number boolean string,ES6中新增了一个叫Symbol的基本数据,它是一个内置全局函数,生成一个独一无二的数据。
<script> let s1 = Symbol(100) let s2 = Symbol(100) //symbol会生成独一无二的数据 console.log(s1, s2, s1 == s2) //Symbol(100) Symbol(100) false var obj = { age: 20 } obj.age = 100 //会覆盖age属性 //用这个可以避免将之前的属性覆盖 function tool(obj) { let age = Symbol("年龄") // obj.age=100 //obj["age"] 这两个不一样 obj[age] = 20 //这里的age是变量名,Symbol的属性名可以是任意值 } </script>
边栏推荐
- 力扣151. 颠倒字符串中的单词
- Three methods of accessing image pixels in opencv
- Phospholipids-Polyethylene Glycol-Active Esters for Scientific Research DSPE-PEG-NHS CAS: 1445723-73-8
- CSDN上markdown编写的一些便捷操作
- ROS service transfer pictures
- DingTalk Enterprise Internal-H5 Micro Application Development
- vs2022 xlua 集成第三方库编译报错Generator Visual Studio 15 2017 could not find any instance of Visual Studio.
- Tensorflow steps on the pit while using it
- 浏览器中的画中画(Picture-in-Picture)API
- 【源码笔记】痛苦来源于比较——什么是相等,hashCode() 和 equals(Object)
猜你喜欢

Cholesterol-PEG-Azide CLS-PEG-N3 Cholesterol-PEG-Azide MW:3400

Pytorch study notes 7 - processing input of multi-dimensional features

浅谈音视频开发入门基础及进阶资源分享

哈希表基础

Research reagents Cholesterol-PEG-Maleimide, CLS-PEG-MAL, Cholesterol-PEG-Maleimide

链表理论基础

Websocket协议解析与QT代码示例

超详细!!!让你通透数组!!!初学复习不迷路!!

【内网开发日记】用websocket手搓一个聊天软件

The content of the wangeditor editor is transferred to the background server for storage
随机推荐
MW: 3400 4-Arm PEG-DSPE four-arm-polyethylene glycol-phospholipid a saturated 18-carbon phospholipid
企业级 DevOps 究竟是什么?
Solution for MySQL The table is full
UR3机器人运动学分析之正运动学分析
DOM操作-事件的绑定与解绑
Wlan实验(ENSP)
Tensorflow related list
mPEG-DSPE 178744-28-0 Methoxy-polyethylene glycol-phosphatidylethanolamine linear PEG phospholipids
虚拟机查看端口号进程
国际站卖家大促攻略,只需要做好这几件事
Four common ways of POST to submit data
力扣.两数之和/四数相加||
力扣.三数之和/四数之和
Unity转微信小游戏与JS交互
Use usb_cam to open multiple cameras at the same time
Software Testing Interview Questions 2021
哈希表基础
Tensorflow——演示
windows下mysql忘记密码登录,并创建用户
关于网络安全法的个人理解