export let A=123; export function test(){ console.log('test'); } export class Hello(){ test(){ console.log('class'); } } import (A,test,Hello) from './class/lesson' or import * as lesson from ''./class/lesson' export 导出 import 导入 or other M…
本文介绍ES6实现模块化的方法:使用import和export. 导入的时候需不需要加大括号的判断:1.当用export default people导出时,就用 import people 导入(不带大括号).2.一个文件里,有且只能有一个export default.但可以有多个export.3.当用export name 时,就用import { name }导入(记得带上大括号).4.当一个文件里,既有一个export default people, 又有多个export name 或者…
默认值 function test(x,y='world'){ console.log('默认值'); } function test2(...arg){ for(let v of arg){ console.log("rest",v); } } test2(1,2,3,4,5,'a'); 箭头函数 let arrow =v=>v*2; console.log('arrow',arrow(3));//6 尾调用---性能优化的过程中,嵌套过多 function tail(x)…
Symbol的概念 变量是独一无二的 let a1=Symbol(); let a2=Symbol(); a1和a2严格意义不相等 let a3=Symbol.for('a3'); let a4=Symbol.for('a3'); console.log(a3===a4); 如果在对象中使用Symbol变量,就可以用Object.getOwnPropertySymbols(obj).forEach(function(tiem){ }) or Reflect.OwnKeys(obj…