JavaScript
in
- 如果指定的属性在指定的对象或其原型链中,则 in 运算符返回 true
- in 运算符
const car = { make: 'Honda', model: 'Accord', year: 1998 };
if ('make' in car) {
console.log(car.make);
}
crypto.randomUUID
let uuid = crypto.randomUUID();
console.log(uuid); // for example "36b8f84d-df4e-4d49-b662-bcde71a8764f"
Intl.DateTimeFormat
- Intl.DateTimeFormat 是根据语言来格式化日期和时间的对象的构造器
- Intl.DateTimeFormat
const date = new Date();
console.log(new Intl.DateTimeFormat('en-US').format(date)); // expected output: '12/17/2021'
console.log(new Intl.DateTimeFormat('zh-CN').format(new D())); // expected output: '2021/12/17'
Array.prototype.at
- Array.prototype.at 方法采用整数值并返回该索引处的元素,允许负数索引
- Array.prototype.at
const list = [5, 12, 8, 130, 44];
console.log(list.at(-1)); // 44
console.log(list.at(-2)); // 130
console.log(list.at(0)); // 5