一、JSON superset将ECMA-262语法扩展为JSON超集动机ECMAScript声称JSON是一个子集JSON.parse,但是(因为已经有详细记录)这是不正确的,因为JSON字符串可以包含未转义的U + 2028 LINE SEPARATOR和U + 2029 PARAGRAPH SEPARATOR字符,而ECMAScript字符串则不能二、Optional catch binding对ECMAScript进行了语法更改,允许catch中不写error捕获动机此提议引入的语法更改允许catch省略绑定其周围的括号原写法try { // 尝试使用可能无法实现的Web功能} catch (unused) { // 支持可能无法实现的web功能情况}以后可以这样写try { // do something} catch { //}三、Symbol.prototype.description新增一个Symbol.prototype.description方法,是一个只读属性,它会返回 Symbol 对象的可选描述的字符串democonsole.log(Symbol(‘desc’).description); // expected output: “desc"console.log(Symbol.iterator.description); // expected output: “Symbol.iterator"console.log(Symbol.for(‘foo’).description); // expected output: “foo"console.log(Symbol(‘foo’).description + ‘bar’); // expected output: “foobar"四、Function.prototype.toString revision新增一个Function.prototype.toString方法,返回一个表示当前函数源代码的字符串1.语法function.toString()2.democonst fun = (name) => { console.log(name) }fun.toString() // “(name) => { console.log(name) }“五、Object.fromEntries ———— 用于将键值对列表转换为对象(兼容性有点差,chrome最新的beta版才支持)。新增Object.fromEntries属性,用于将键值对列表转换为对象1.语法const newObject = Object.fromEntries(iterable);iterable: 类似实现了可迭代协议 Array 或者 Map 或者其它对象的可迭代对象2.democonst newObject = Object.fromEntries([[‘a’, 1], [‘b’, 2]]); // { a: 1, b: 2 }const map = new Map().set(‘a’, 1).set(‘b’, 2);const newObject1 = Object.fromEntries(map); // { a: 1, b: 2 }六、Well-formed JSON.stringify防止JSON.stringify返回格式错误的Unicode字符串的提议七、String.prototype.{trimStart,trimEnd}新增String.prototype.trimStart和String.prototype.trimEnd属性,移除空白字符,并返回一个新字符串String.prototype.trimStart从一个字符串的开端删除空白字段,并返回一个新字符串1.语法str.trimStart();2.democonst str = ’ 我愿是猪 ‘;const newStr = str.trimStart(); // ‘我愿是猪 ‘String.prototype.trimEnd从一个字符串的末端删除空白字段,并返回一个新字符串1.语法str.trimEnd();2.democonst str = ’ 我愿是猪 ‘;const newStr = str.trimEnd(); // ’ 我愿是猪’八、Array.prototype.{flat,flatMap}新增Array.prototype.flat和Array.prototype.flatMap属性,对数组的内含数组进行展开操作并返回一个新数组Array.prototype.flat!参考资料方法会按照一个可指定的深度递归遍历数组,并将所有元素与遍历到的子数组中的元素合并为一个新数组返回1.语法const newArray = arr.flat(depth)depth: 需要展开内层数组的层数,默认为12.demo展开内层数组/** 默认参数: /const array = [1, [2, [3]]];const array1 = array.flat(); // [1, 2, [3]]/* 递归展平,直到数组不再包含嵌套数组: /const arrayInfinity = array.flat(Infinity); // [1, 2, 3]/* 此处等同于 */const array2 = array.flat(2);移除空项const array = [1, 2, , 3];const arrayRemove = array.flat(); // [1, 2, 3]Array.prototype.flatMap方法类似与Array.prototype.map,但是会展开数组(只会展开一层)1.语法const new_array = arr.flatMap((currentValue, index, array) => { // 返回新数组的元素})currentValue: 数组中正在处理的当前元素index: 正在处理元素的索引array: 正在被处理素组2.democonst array = [1, 2, 3];const new_array = array.flatMap(ele => [ele * 2]) // [2, 4, 6]const new_array2 = array.flatMap(ele => [[ele * 2]]) // [[2], [4], [6]]gitub上修改