[Javascirpt] What’s new in JavaScript (Google I/O ’19)
2024-09-05 09:25:08
Private variable in class:
class Counter {
#count = 0; // cannot be access publicly get value () {
return this.#count;
} incremenet(){
this.#count++;
}
}
class field syntax:
Previously you need to call 'super'
class Animal {
constructor (name) {
this.name = name
}
} class Cat extends Animal {
constructor (name) {
super(name);
this.likesBaths = false;
}
meow () {
// ...
}
}
But now, we don't need to, you can use classs field:
class Animal {
constructor (name) {
this.name = name
}
} class Cat extends Animal {
likesBaths = false;
meow () {
// ...
}
}
Above two features are supported in latest Chrome and Node.js.
flatMap:
const duplicate = x => [x, x];
console.log([2,3,4].flatMap(duplicate)); // [2, 2, 3, 3, 4, 4]
Object.fromEntries:
Reverse opreation of Object.entries, it transform [['x', 42], ['y', 50]] too {x: 42, y: 50}:
const object = {x: 42, y: 50, abc: 9001}
const result = Object.fromEntries(
Object.entries(object)
.filter(([key, value]) => key.length === 1) // only take x, y, ingore abc
.map(([key, value]) => [key, value * 2])
) // {x: 84, y: 100}
It is also support to transform back and from Javascirpt Map.
globalThis:
using 'globalThis' to handle all the envs.
Intl:
最新文章
- Python练习,网络小爬虫(初级)
- C语言typedef的用法(转)
- .frame类库简单介绍与使用
- JSP-08-第三方控件的使用
- NKW
- Spring中依赖注入的使用和配置
- 解析php mysql 事务处理回滚操作(附实例)
- HDOJ2016数据的交换输出
- ubuntu下设置开机自启动项
- MongoDB学习笔记05
- 有关windows在调试ODOO8.0有些问题
- C# 与 C++强强联合--C#中的指针
- go defer笔记
- BASH 基本语法
- Linux开机执行指定shell
- pandas shift
- MATLAB中版本和日期函数
- 如何配置Linux系统防火墙,以防止DDOS攻击?
- [转]greenplum(postgresql)之数据字典
- CentOS忘记普通用户密码解决办法
热门文章
- [SDOI2013]直径 题解
- 解决Another app is currently holding the yum lock; waiting for it to exit...问题
- csp模拟赛低级错误及反思
- PHP+jQuery.photoClip.js支持手势的图片裁剪上传实例
- Codeforces 1238C. Standard Free2play
- maven 常见命令 学习笔记(一)之 -pl -am -amd
- (转载)项目中表、类、包、JSP命名规范
- python numpy 的用法—— bincount
- redis的keys常用操作及redis的特性
- Linux之用户相关操作