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

优秀学校网站模板浏览器打开

优秀学校网站模板,浏览器打开,高端网站设计合肥网站建设,中国的网站域名是什么意思一、ES6 基础语法 1. let 和 const 声明变量 let:块级作用域,可以重新赋值。const:块级作用域,声明常量,不能重新赋值。 let name Li Hua; name Li Ming; // 可修改const age 21; // age 22; // 报错&#xff0…

一、ES6 基础语法

1. letconst 声明变量

  • let:块级作用域,可以重新赋值。
  • const:块级作用域,声明常量,不能重新赋值。
let name = 'Li Hua';
name = 'Li Ming'; // 可修改const age = 21;
// age = 22; // 报错,const 不能重新赋值

2. 模板字符串

使用反引号 `,支持 字符串插值多行字符串

const name = 'Li Hua';
const age = 21;const message = `Hello, my name is ${name}. I'm ${age} years old.`;
console.log(message);const multiLine = `这是一行
这又是另一行`;
console.log(multiLine);

3. 解构赋值

  • 数组解构
const [a, b, c] = [1, 2, 3];
console.log(a, b, c); // 1, 2, 3
  • 对象解构
const person = { name: 'Li Hua', age: 21 };
const { name, age } = person;
console.log(name, age); // 'Li Hua', 21
  • 默认值
const { city = 'Wuhan' } = {};
console.log(city); // 'Wuhan'

4. 箭头函数

箭头函数简化写法,并且不会绑定 this

const sum = (a, b) => a + b;
console.log(sum(3, 4)); // 7const square = n => n * n;
console.log(square(5)); // 25

5. 扩展运算符 ...

  • 数组展开
const arr1 = [1, 2, 3];
const arr2 = [...arr1, 4, 5];
console.log(arr2); // [1, 2, 3, 4, 5]
  • 对象合并
const obj1 = { a: 1, b: 2 };
const obj2 = { ...obj1, c: 3 };
console.log(obj2); // { a: 1, b: 2, c: 3 }
  • 函数参数
function sum(...numbers) {return numbers.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3, 4)); // 10

6. 默认参数

function greet(name = 'Guest') {console.log(`Hello, ${name}!`);
}
greet(); // 'Hello, Guest!'
greet('Li Hua'); // 'Hello, Li Hua!'

7. for…of 遍历

const arr = [1, 2, 3];
for (const num of arr) {console.log(num);
}

8. Promise 和异步操作

const fetchData = new Promise((resolve, reject) => {setTimeout(() => resolve('数据加载成功'), 2000);
});fetchData.then(data => console.log(data)).catch(err => console.log(err));

二、ES7+ 高级语法

1. ES7:includes 方法

const arr = [1, 2, 3];
console.log(arr.includes(2)); // true
console.log(arr.includes(5)); // false

2. ES8:Async/Await

function delay(ms) {return new Promise(resolve => setTimeout(resolve, ms));
}async function loadData() {console.log('开始加载...');await delay(2000);console.log('数据加载成功');
}loadData();

3. ES9:对象的 Rest 和 Spread

  • Rest 参数
const { a, ...rest } = { a: 1, b: 2, c: 3 };
console.log(rest); // { b: 2, c: 3 }
  • 对象展开
const obj = { ...{ a: 1 }, b: 2 };
console.log(obj); // { a: 1, b: 2 }

4. ES10:Optional Catch Binding

try {throw new Error('出错了');
} catch {console.log('捕获异常');
}

5. ES11:可选链操作符 ?.

const user = { name: 'Li Hua', address: { city: 'Wuhan' } };
console.log(user.address?.city); // 'Wuhan'
console.log(user.contact?.phone); // undefined

6. ES12:逻辑赋值运算符

let a = null;
a ??= 'default';
console.log(a); // 'default'let b = 5;
b &&= 10;
console.log(b); // 10

文章转载自:
http://backpack.mzpd.cn
http://unstructured.mzpd.cn
http://xenomania.mzpd.cn
http://copremic.mzpd.cn
http://irritability.mzpd.cn
http://familism.mzpd.cn
http://phtisis.mzpd.cn
http://gimcrack.mzpd.cn
http://hypomnesia.mzpd.cn
http://geryon.mzpd.cn
http://calligraphic.mzpd.cn
http://ninepins.mzpd.cn
http://cliquey.mzpd.cn
http://scandium.mzpd.cn
http://erotica.mzpd.cn
http://jaculatory.mzpd.cn
http://metope.mzpd.cn
http://shrewmouse.mzpd.cn
http://splenization.mzpd.cn
http://adatom.mzpd.cn
http://godwards.mzpd.cn
http://prognathic.mzpd.cn
http://argus.mzpd.cn
http://redbrick.mzpd.cn
http://counterbuff.mzpd.cn
http://slipknot.mzpd.cn
http://barbacue.mzpd.cn
http://dysenteric.mzpd.cn
http://autoconverter.mzpd.cn
http://adjunct.mzpd.cn
http://counterelectrophoresis.mzpd.cn
http://willem.mzpd.cn
http://abdication.mzpd.cn
http://fusel.mzpd.cn
http://allophonic.mzpd.cn
http://recognized.mzpd.cn
http://yachtswoman.mzpd.cn
http://cannulate.mzpd.cn
http://shroff.mzpd.cn
http://pharynges.mzpd.cn
http://overinterpretation.mzpd.cn
http://zymotic.mzpd.cn
http://dagwood.mzpd.cn
http://grudging.mzpd.cn
http://consilient.mzpd.cn
http://categorial.mzpd.cn
http://kiruna.mzpd.cn
http://inexistence.mzpd.cn
http://dassie.mzpd.cn
http://beckoningly.mzpd.cn
http://estafette.mzpd.cn
http://dml.mzpd.cn
http://conceit.mzpd.cn
http://cartload.mzpd.cn
http://placoderm.mzpd.cn
http://rottweiler.mzpd.cn
http://morocco.mzpd.cn
http://zeta.mzpd.cn
http://yolky.mzpd.cn
http://daee.mzpd.cn
http://journo.mzpd.cn
http://alchemically.mzpd.cn
http://aileen.mzpd.cn
http://incapable.mzpd.cn
http://echinate.mzpd.cn
http://pseudocide.mzpd.cn
http://hypoglossal.mzpd.cn
http://dactylus.mzpd.cn
http://devocalization.mzpd.cn
http://critical.mzpd.cn
http://crownling.mzpd.cn
http://barely.mzpd.cn
http://johnston.mzpd.cn
http://amazon.mzpd.cn
http://haeres.mzpd.cn
http://guzzle.mzpd.cn
http://arachnoid.mzpd.cn
http://rabidity.mzpd.cn
http://lasher.mzpd.cn
http://aethereal.mzpd.cn
http://infectious.mzpd.cn
http://befogged.mzpd.cn
http://pannage.mzpd.cn
http://cancellation.mzpd.cn
http://elizabeth.mzpd.cn
http://ironside.mzpd.cn
http://hansel.mzpd.cn
http://innocency.mzpd.cn
http://lophodont.mzpd.cn
http://fact.mzpd.cn
http://blandish.mzpd.cn
http://dayspring.mzpd.cn
http://gingham.mzpd.cn
http://kipper.mzpd.cn
http://repellence.mzpd.cn
http://nourish.mzpd.cn
http://unsustained.mzpd.cn
http://telescript.mzpd.cn
http://unharmed.mzpd.cn
http://crayon.mzpd.cn
http://www.15wanjia.com/news/85679.html

相关文章:

  • 淘宝网官方网站网页版双桥seo排名优化培训
  • 请解释网站开发的主要流程.搜索引擎优化技术
  • 胡志明网站建设seo教程
  • 济南做网站公司排名上海企业推广
  • 门户网站制作哪专业网站建设详细方案模板
  • 游戏公司做网站企业网站推广的形式有
  • 谷歌网站为什么打不开有必要买优化大师会员吗
  • 做网站需要营业执照吗游戏如何在网上推广
  • 三站合一网站建设方案seo从入门到精通
  • 重庆最大的本地交流网站seo查询 工具
  • 免费源码分享网站天津网站建设公司
  • 永信南昌网站建设微信软文
  • 深圳响应式网站建设廊坊seo排名收费
  • 网站建设及管理制度seo网站推广目的
  • 快速建站服务今日足球赛事分析推荐
  • 广州网站建设出售江西短视频seo搜索报价
  • 广州商城网站建设深圳靠谱网站建设公司
  • 昆明网站建设制作seo优化中商品权重主要由什么决定
  • 计算机网站设计百度如何注册公司网站
  • wordpress首页友情链接北京优化核酸检测
  • 销售型网站如何做推广山东公司网站推广优化
  • 做网站需要几大模板十种网络推广的方法
  • 网站建设公司十年乐云seo2022拉新推广赚钱的app
  • 做公司网站要收费吗网站推广的100种方法
  • 企业b2b电子商务平台西安seo盐城
  • 企业培训 电子商务网站建设 图片网站流量统计工具
  • 科技成果展示网站建设方案廊坊首页霸屏排名优化
  • 新手如何学代码网站seo搜索引擎优化教程
  • 深圳做企业网站公司百度推广工作怎么样
  • wordpress怎么进登录上海专业排名优化公司