// https://segmentfault.com/a/1190000002904199
// => 是function的简写形式,支持expression 和 statement 两种形式
/*
语法:
([param] [, param]) => {
statements
}
param => expression
*/
arr.map(item=>item+1);
arr.map((item,index))=>item+1)
var lan{
name:'',
frends:['xiaozhong','dajie']
count:function(){
this.frends.forEach(item=>{console.log(item);
});
}
}
// ES6 引入了class(类),让javascript的面向对象编程变得更加容易清晰和容易理解
// 类的 prototype 属性和 __proto__ 属性
class Cat extends Animal {}
console.log(Cat.__proto__ === Animal); // true
console.log(Cat.prototype.__proto__ === Animal.prototype); // true
console.log(A.__proto__ === Object); // true
console.log(A.prototype.__proto__ === Object.prototype);
console.log(Cat.__proto__ === Function.prototype); //true
console.log(Cat.prototype.__proto__ === Object.prototype); //true
// 模块的功能主要由 export 和 import 组成.
// 每一个模块(Module)都有自己单独的作用域,模块之间的相互调用关系是通过 export 来规定模块对外暴露的接口,
// 通过import来引用其它模块提供的接口。同时还为模块创造了命名空间,防止函数的命名冲突。
var a="hellp";// ES6将一个文件视为一个模块,上面的模块通过 export 向外输出了一个变量。一个模块也可以同时往外面输出多个变量。
var b="world";
export{a,b};//export是es6的一个命令
export function getA(){
return a;
}
export default function getAge() {} default 导出
// 在另外一个文件中引入
import {name, age} from './test.js'
import * as test form './test.js';
module test from 'test.js';
test.getName();//test 为模块名
import test from './test.js';// 导入的时候不需要花括号
import getAge, { getA } from './test.js';//一条import 语句可以同时导入默认方法和其它变量.