当前位置:网站首页>ES6知识点补充
ES6知识点补充
2022-07-28 11:10:00 【卷王出征】
Symbol
symbol是数据类型的一种,已有的数据类型
基本数据类型:
字符串、布尔、数字、null、undefined、symbol、bigInt(大于9007199254740992的数)
引用数据类型:
对象(对象、数组、函数)等
Symbol.for()与Symbol()这两种写法,都会生成新的 Symbol
let sy = Symbol('a')
let sy1 = Symbol('a')
sy === sy1 // false
let s1 = Symbol.for('foo');
let s2 = Symbol.for('foo');
s1 === s2 // true
以上可以看出,Symbol就算是传入相同的key,返回的数也不同。
Symbol.for()传值 会判断传入的值是否存在,如果不存在,才返回一个新的值。
class类
类的初体验
class Obj {
constructor(one, two) {
this.one = one;
this.two = two;
}
hello() {
console.log("hello");
}
}
let obj = new Obj(1,2);
obj.hello();
console.log(obj);
hello
Obj {
one: 1, two: 2}
constructor (在实例化的时候),接收实例化时传的值,然后自动执行constructor本身。
类的静态成员
class Obj {
} 或者
function Obj() {
}
Obj.name = "fujin";
let obj = new Obj();
console.log(obj); //空对象,没有被添加上属性
因为name只属于Obj这个类或者构造函数,不属于实例对象,这就是类的静态成员,要是想实例对象可以使用name,可以用Obj.prototype.name= "fujin"
同样,在class中,如果要是使用static关键字,那么久等同于Obj.name = ‘fujin’
class Obj {
static name = 'fujin'
}
边栏推荐
- Update dev (development version) of the latest win11
- R语言-用于非平衡数据集的一些度量指标
- Top ten application development trends from 2022 to 2023
- Minikube initial experience environment construction
- 什么样的知识付费系统功能,更有利于平台与讲师发展?
- Full version of H5 social chat platform source code [complete database + complete document tutorial]
- LabVIEW AI visual Toolkit (non Ni vision) download and installation tutorial
- Install SSL Certificate in Litespeed web server
- Software testing and quality learning notes 1 --- black box testing
- Why does MySQL sometimes choose the wrong index?
猜你喜欢

数字孪生轨道交通:“智慧化”监控疏通城市运行痛点

Will PFP be the future of digital collections?

PKG packaging node project

Autumn recruit offer harvesters, and take the offers of major manufacturers at will

Server online speed measurement system source code

Install SSL Certificate in Litespeed web server

Digital twin rail transit: "intelligent" monitoring to clear the pain points of urban operation

AlexNet—论文分析及复现

Three methods of using unity mouse to drive objects

Six papers that must be seen in the field of target detection
随机推荐
小水滴2.0网站导航网模板
[half understood] zero value copy
Router firmware decryption idea
【一知半解】零值拷贝
[geek challenge 2019] babysql-1 | SQL injection
保障邮箱安全,验证码四个优势
[MySQL] query multiple IDs and return string splicing
Random talk on GIS data (V) - geographic coordinate system
[极客大挑战 2019]BabySQL-1|SQL注入
[collection] Advanced Mathematics: Capriccio of stars
Full version of H5 social chat platform source code [complete database + complete document tutorial]
echo -ne(echo line)
PHP检测url网址链接是否正常可访问
R language uses LM function to build regression model and regression model for transformed data (for example, it is necessary to build regression model for X and y, but they have no linear relationshi
R language - some metrics for unbalanced data sets
数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
Introduction to the usage of SAP ui5 image display control avatar trial version
CVPR2020 best paper:对称可变形三维物体的无监督学习
B2 sub theme / blog b2child sub theme / open source code
How to effectively implement a rapid and reasonable safety evacuation system in hospitals