当前位置: 首页 > news >正文

抄袭网站怎么办网站收录网

抄袭网站怎么办,网站收录网,国外网站怎么做引流,设计名字的网站Array.prototype.toSorted() 返回一个新的已排序数组副本,不改变原数组。 let arr [5, 4, 2, 3, 1]; console.log(arr.toSorted()); // [1, 2, 3, 4, 5]Array.prototype.with() 允许根据索引修改数组中的单个元素,并返回新数组。 const arr ["…
  1. Array.prototype.toSorted()

返回一个新的已排序数组副本,不改变原数组。

let arr = [5, 4, 2, 3, 1];
console.log(arr.toSorted()); // [1, 2, 3, 4, 5]
  1. Array.prototype.with()

允许根据索引修改数组中的单个元素,并返回新数组。

const arr = ["I", "am", "rex"];
const newArr = arr.with(2, "Ape Man");
console.log(newArr); // ["I", "am", "Ape Man"]
  1. Array.prototype.toReversed()

类似于 reverse(),但返回一个新的数组而不是原地操作。

console.log(["1", "2", "3", "4", "5"].toReversed()); // ['5', '4', '3', '2', '1']
  1. Array.prototype.findLast

从数组中获取最后一个匹配元素的实例。

const arr = [24, 34, 55, 75, 10, 77];
console.log(arr.findLast(element => element % 2 === 0)); // 10
  1. Array.prototype.findLastIndex()

与 findLast() 类似,但返回匹配元素的索引。

const arr = [24, 34, 55, 75, 10, 77];
console.log(arr.findLastIndex(element => element % 2 === 0)); // 4
  1. Array.prototype.toSpliced()

类似于数组的 splice 方法,但返回一个新数组。

const arr = [1, 2, 3, 4];
console.log(arr.toSpliced(2, 0, 'a', 'b')); // [1, 2, 'a', 'b', 3, 4]
  1. Hashbang 支持

允许在脚本文件的第一行使用 #! 开头来指定解释器路径。这对于运行时环境(如 Node.js)特别有用。

#!/usr/bin/env node
console.log("This is a script with hashbang support.");
  1. 使用 Symbol 作为 WeakMap 键

扩展了 WeakMap 和 WeakSet 的功能,允许使用 Symbol 作为键。

const weakMap = new WeakMap();
const key = Symbol('key');
const obj = {};
weakMap.set(key, obj);
console.log(weakMap.get(key)); // 输出: {}
  1. Intl.NumberFormat.prototype.formatRangeToParts

提供了一种方法来格式化数字范围,并返回格式化的部分数组。

const numberFormat = new Intl.NumberFormat('en', { style: 'currency', currency: 'USD' });
console.log(numberFormat.formatRangeToParts(5, 10));
  1. Intl.NumberFormat.prototype.formatRangeToParts

提供了一种方法来格式化数字范围,并返回格式化的部分数组。

const numberFormat = new Intl.NumberFormat('en', { style: 'currency', currency: 'USD' });
console.log(numberFormat.formatRangeToParts(5, 10));
  1. Error Cause

在创建错误对象时可以传递一个原因对象,帮助追踪错误来源。

try {throw new Error("An error occurred", { cause: "Some additional context" });
} catch (e) {console.error(e.message, e.cause); // 输出: An error occurred Some additional context
}
  1. FinalizationRegistry Cleanup Callbacks

提供了一个机制来注册回调函数,当垃圾回收器清除注册表中的条目时调用。

const registry = new FinalizationRegistry((heldValue) => {console.log(`Cleaned up ${heldValue}`);
});
let obj = {};
registry.register(obj, "some value");
obj = null; // 假设此时 obj 被垃圾回收
  1. Promise.withResolvers()

返回一个新的 Promise 对象和对应的 resolve/reject 函数。

const { promise, resolve, reject } = Promise.withResolvers();
promise.then(value => console.log(value)); // 当 resolve 被调用时输出值
resolve("resolved value");
  1. Top-Level Await in Modules

允许在模块顶层使用 await,而不仅仅是在异步函数内部。

await someAsyncFunction(); // 直接在模块顶层使用 await
  1. Logical Assignment Operators

引入了逻辑赋值操作符:&&=||=??=,这些操作符结合了逻辑运算与赋值。

let a; a &&= 5; // 等价于 a = a && 5;

  1. Numeric Separators

允许在数字字面量中使用下划线 _ 作为千位分隔符以提高可读性。

const budget = 1_000_000_000_000; // 一千亿
  1. Class Fields and Static Class Features

支持类字段声明和静态类特性,简化类定义。

class MyClass {field = "a field";static staticField = "a static field";
}
http://www.bjxfkj.com.cn/article/104810.html

相关文章:

  • 用虚拟机做服务器搭建网站站长工具网站推广
  • 专业广州网站建设百度一下你就知道下载安装
  • 国外网站怎么上巢湖网站制作
  • 在哪了做网站semi final
  • 网站后台登陆不了搜狗整站优化
  • 企业网站主题大连中小企业网络营销
  • 昆明市党风廉政建设网站百度灰色关键词代发
  • 触摸屏网站如何做站长域名查询
  • 设计学网站昆明长尾词seo怎么优化
  • wordpress dokan长春seo公司
  • wordpress 用户登陆后跳转到首页东莞seo排名公司
  • 武汉市做网站的公司河北seo推广方案
  • 陕西网站建设的内容谷歌浏览器搜索入口
  • 做美图网站有哪些东西茶叶网络营销策划方案
  • 网站执行速度关键seo排名点击软件
  • 12306网站是哪个公司做的数据分析培训班
  • 推广软件app赚钱联盟网站优化 seo和sem
  • 做网站动图的软件西安seo顾问培训
  • 工业设计网官网东莞seo计费
  • 做网站常州万网域名注册流程
  • 网站运营今天晚上19点新闻联播直播回放
  • 音乐网站开发四川seo选哪家
  • 问答网站开发江东怎样优化seo
  • 硅胶鞋垫移动网站建设网站优化哪个公司好
  • 网站开发工程师 面试英语seo关键词排名优化系统
  • 网站制作的页面比例优化营商环境的意义
  • 网站建设服务商 需要什么主机百度关键词优化平台
  • 临桂住房和城乡建设委员会网站长沙seo男团
  • 做带支付平台的网站网站怎么被收录
  • 用美国服务器做中国盗版网站平台引流推广怎么做