原文链接: js es10 新特性

上一篇: python acm 坐标移动 正则表达式

下一篇: python opencv 交叉淡化

原文
ES10 功能完全指南

在过去的整数值大于9007199254740992不支持。如果超出,则该值将锁定为 MAX_SAFE_INTEGER + 1

加法需要类型相同

const limit = Number.MAX_SAFE_INTEGER;
console.log(limit) // 9007199254740991
console.log(limit + 1) // 9007199254740992
console.log(limit + 2) // 9007199254740992const larger = 9007199254740991n;
console.log(larger, larger + 2n) // 9007199254740991n 9007199254740993nconst integer = BigInt(9007199254740991); // initialize with number
console.log(integer, integer + 2n) // 9007199254740991n 9007199254740993nconst same = BigInt("9007199254740991"); // initialize with "string" 9007199254740991n
console.log(same, same + 2n) // 9007199254740991n 9007199254740993nconsole.log(typeof 1, typeof 1n) // number bigint

数组扁平化

let multi = [1, 2, 3, [4, 5, 6, [7, 8, 9, [10, 11, 12]]]];
multi.flat();               // [1,2,3,4,5,6,Array(4)]
multi.flat().flat();        // [1,2,3,4,5,6,7,8,9,Array(3)]
multi.flat().flat().flat(); // [1,2,3,4,5,6,7,8,9,10,11,12]
multi.flat(Infinity);       // [1,2,3,4,5,6,7,8,9,10,11,12]
let array = [1, 2, 3, 4, 5]
array.map(x => [x, x * 2])
// [Array(2), Array(2), Array(2)]
// 0: (2)[1, 2]
// 1: (2)[2, 4]
// 2: (2)[3, 6]
// 3: (2)[4, 8]
// 4: (2)[5, 10]array.flatMap(v => [v, v * 2])
// [1, 2, 2, 4, 3, 6, 4, 8, 5, 10]

对象键值对遍历

let obj = {apple: 10, orange: 20, banana: 30};
let entries = Object.entries(obj);
// entries;
// (3) [Array(2), Array(2), Array(2)]
// 0: (2) ["apple", 10]
// 1: (2) ["orange", 20]
// 2: (2) ["banana", 30]
let fromEntries = Object.fromEntries(entries);
// { apple: 10, orange: 20, banana: 30 }

稳定排序

var fruit = [{name: "Apple", count: 13,},{name: "Pear", count: 12,},{name: "Banana", count: 12,},{name: "Strawberry", count: 11,},{name: "Cherry", count: 11,},{name: "Blackberry", count: 10,},{name: "Pineapple", count: 10,}
];
// Create our own sort criteria function:
let my_sort = (a, b) => a.count - b.count;
// Perform stable ES10 sort:
let sorted = fruit.sort(my_sort);
console.log(sorted);

js es10 新特性相关推荐

  1. JS:ES10新特性

    概述: 1.Object.fromEntries:将二维数组或者map转换成对象(相对于Object.entries是将对象转换成二维数组): 2.trimStart 和 trimEnd:去除字符串前 ...

  2. [转]ES7、ES8、ES9、ES10新特性大盘点

    ES7.ES8.ES9.ES10新特性大盘点 本文转自:https://mp.weixin.qq.com/s/8bov6788ivV0sHzmwrn5lw 以下文章来源于前端工匠 ,作者浪里行舟君 前 ...

  3. [转]ES6、ES7、ES8、ES9、ES10新特性一览 (个人整理,学习笔记)

    目录 1.ES6新特性(2015) 1.1模块化(Module) 1.1.1导出(export) 1.1.2导入(import) 1.2箭头(Arrow)函数 1.2.1箭头函数的结构 1.3默认参数 ...

  4. ES6、ES7、ES8、ES9、ES10新特性一览

    ES全称ECMAScript,ECMAScript是ECMA制定的标准化脚本语言.目前JavaScript使用的ECMAScript版本为ECMA-417.关于ECMA的最新资讯可以浏览 ECMA n ...

  5. ES7、ES8、ES9、ES10新特性大盘点

    前言 从 ECMAScript 2016(ES7)开始,版本发布变得更加频繁,每年发布一个新版本,好在每次版本的更新内容并不多,本文会细说这些新特性,尽可能和旧知识相关联,帮你迅速上手这些特性. ES ...

  6. ES6、 ES7、 ES8、 ES9、 ES10 新特性概览

    传送门:ES11.ES12.ES13 新特性概览 ES全称ECMAScript,ECMAScript是ECMA制定的标准化脚本语言.目前JavaScript使用的ECMAScript版本为ECMA-4 ...

  7. JavaScript的ES6、ES7、ES8、ES9、ES10新特性

    ES6.ES7.ES8.ES9.ES10新特性 ES全称ECMAScript,ECMAScript是ECMA制定的标准化脚本语言.目前JavaScript使用的ECMAScript版本为ECMA-41 ...

  8. ES6、ES7、ES8、ES9、ES10 新特性ECMAScript版本简介

    ES全称ECMAScript,ECMAScript是ECMA制定的标准化脚本语言 ES6新特性(2015) ES6的特性比较多,在 ES5 发布近 6 年(2009-11 至 2015-6)之后才将其 ...

  9. ES9新特性、ES10新特性

    ES9新特性 一.rest参数与spread扩展运算符 rest参数与spread扩展运算符在es6中已经引入,不过es6中只针对于数组,在es9中为对象提供了像数组一样的rest参数和扩展运算符 1 ...

最新文章

  1. Python练习-循环及切片-2018.11.27
  2. python制作工资计算器-Python制作个税计算器
  3. 《网络攻防实践》第二周学习总结
  4. php文件目录操作相关
  5. Android权限之动态权限
  6. JS之数据类型v(** v**)v个人笔记
  7. linux汇编字符长怎么看,linux – 在内联GNU汇编程序中获取字符串长...
  8. Silverlight 2 Beta 1学习资源
  9. android ssl-dl
  10. java bufferedreader读大文件会内存溢出吗_【JVM成长系列】实战内存溢出异常
  11. Gns3模拟器配置Cisco ASA防火墙
  12. Java语言实现会议安排问题,利用贪心法思想解决问题
  13. 20 个有用的 Go 语言微服务开发框架吐血总结!!!
  14. 2022年第七届IEEE云计算与大数据分析国际会议
  15. windows10 20H2版本微软账户登录不上解决方法
  16. Codeforces 1129C - Morse Code
  17. bzoj3238 [Ahoi2013]差异 后缀自动机
  18. 【云和恩墨业务介绍】之超融合存储解决方案 - zData Light Storage
  19. 基于python的医学图像以辅助医疗系统
  20. 直尺刻度识别_怎样用刻度尺测量长度

热门文章

  1. 第一批用ChatGPT搞副业的程序员,已经富起来了
  2. 远程桌面工具TeamViewer模块介绍——计算机 联系人选项卡
  3. 在Anaconda3使用Jupyter Notebook的简单例子
  4. 浪潮服务器的开始虚拟化选项,浪潮服务器虚拟化解决方案.pptx
  5. 编程常用Mac快捷键
  6. javaweb ssh2 第一个网站 半米社区终于开始测试啦
  7. weblogic清理缓存方法
  8. Bash脚本编程之算术运算
  9. What is important ?
  10. 物流管理考研需要考计算机吗,物流管理考研要考哪些