ES6
项哈哈想做前端
前端菜鸟,在线互啄。
展开
-
babel转换ES6为ES5
准备几个js文件。// test1export default { hobbit: function () { console.log('唱歌') }}// test2const age = 18;function talk() { console.log('今年18')}export { age, talk}// test3export const name = '张三';export function speck() {原创 2022-01-13 20:22:42 · 1932 阅读 · 0 评论 -
ES6-解构赋值
ES6 允许按照一定模式从数组和对象提取值,对变量进行赋值数组的解构赋值const list = ["张三", "李四", "王五"];const [a, b, c] = list;console.log(a); // 张三console.log(b); // 李四console.log(c); // 王五对象的解构赋值const obj = { name: "张三", age: 18, speck: function () { console.log("今年1原创 2021-12-02 19:47:45 · 549 阅读 · 0 评论 -
ES6-let、const变量声明及声明特性
var//声明变量let a;// orlet b, c, d;// orlet e = [];声明变量的特性变量不能重复声明<script>let name = "张三"; let name = "李四";</script>Uncaught SyntaxError: Identifier 'name' has already been declared未捕获的语法错误:已声明标识符“name”块级作用域在 es5 中有三种作用域,分别是全局,原创 2021-12-02 19:47:27 · 659 阅读 · 0 评论