1. 箭头函数没有自己的this,它里面的this是继承所属上下文中的this,而且使用call与apply都无法改变
let obj = {
name: 'obj'
}
function fn1() {
console.log(this);
} fn1.call(obj); let fn2() => {
console.log(this);
}
fn2.call(obj);
2. 普通函数的参数是arguments,而箭头函数是arg
let arr = [1,2,3]
~function(){
console.log(arguments);
}
(arr); //输出 [1,2,3]
let a = (...arg) => {
console.log(arg);
}
a(arr) //输出[1,2,3]
3. 语法上比普通函数更加简洁
function fn1(x) {
return function(y) {
return x + y;
}
} let fn1 = x => y => x + y;
4. 箭头函数不能使用new生成构造函数,因为箭头函数没有prototype,而construct在prototype里面。
function Fn1() {
this.x = 100;
}
let f1 = new Fn1; let Fn2 = () => {
this.x = 200;
} let f2 = new Fn2; //输出 Fn2 is not a constructor

最新文章

  1. Spring:Aop before after afterReturn afterThrowing around 的原理
  2. 超链接a标签
  3. css性能优化
  4. Java使用占位符拼接字符串
  5. .NET 分页
  6. Centos7下用命令下载jdk7及jboss-eap-6
  7. tomcat 集群配置,Session复制共享
  8. requirejs实验001.对我来说,用AMD的方式来组织代码并不轻松.
  9. 在用VS2010连接oracle数据库时ORA-12504错误
  10. 《Principles of Mathematical Analysis》-chaper1-实数系与复数系
  11. Model和Entity Framework
  12. Windows下Nginx的安装与使用(一):配置端口转发
  13. hdu1394 分治 or 线段树
  14. Visual Studio 2010多线程编程
  15. 页面读取Excel
  16. holer实现外网访问本地网站
  17. Python中Celery 的基本用法以及Django 结合 Celery 的使用和实时监控进程
  18. js 表达式与语句
  19. MySql常用命令集Mysql常用命令3
  20. jquery获取input file的文件名,具有兼容性

热门文章

  1. USACO2008 Jan 电话网络
  2. 关系型数据库---MYSQL---优化
  3. Angular JS - 3 - Angular JS 双向数据绑定
  4. mybatis的Date类型。
  5. BUUCTF | [HCTF 2018]admin
  6. iOS 开发加密做法
  7. 如何利用nginx实现负载均衡(总结)
  8. xcodebuild 自动化打包
  9. stl源码为什么要大量使用typedef?
  10. Html5 学习笔记 【PC固定布局】 实战4 footer 区域