ES6及后续版本为JavaScript带来了许多强大的新特性。
箭头函数
const add = (a, b) => a + b;
const square = x => x * x;解构赋值
const { name, age } = person;
const [first, ...rest] = array;Promise与Async/Await
async function fetchData() {
try {
const response = await fetch(url);
const data = await response.json();
return data;
} catch (error) {
console.error(error);
}
}模块化
export const pi = 3.14159;
import { pi } from './math.js';
评论 (0)
暂无评论,来发表第一条评论吧!
发表评论