ES6 In Depth: Arrow functions
Arrows
<script language="javascript">
<!--
document.bgColor = "brown"; // red
// -->
</script>
Old browsers would see two unsupported tags and a comment; only new browsers would see JS code.
To support this odd hack, the JavaScript engine in your browser treats the characters <!-- as the start of a one-line comment. No joke. This has really been part of the language all along, and it works to this day, not just at the top of an inline <script> but everywhere in JS code. It even works in Node.
As it happens, this style of comment is standardized for the first time in ES6.
The arrow sequence --> also denotes a one-line comment. Weirdly, while in HTML characters before the --> are part of the comment, in JS the rest of the line after the --> is a comment.
It gets stranger. This arrow indicates a comment only when it appears at the start of a line. That’s because in other contexts, --> is an operator in JS, the goes to operator!
function countdown(n) {
while (n --> 0) // "n goes to zero"
alert(n);
blastoff();
}
A new arrow in your quiver
What’s this?
Using arrows to pierce the dark heart of computer science
原文:ES6 In Depth: Arrow functions
ES6 In Depth: Arrow functions的更多相关文章
- 《理解 ES6》阅读整理:函数(Functions)(四)Arrow Functions
箭头函数(Arrow Functions) 就像名字所说那样,箭头函数使用箭头(=>)来定义函数.与传统函数相比,箭头函数在多个地方表现不一样. 箭头函数语法(Arrow Function Sy ...
- JavaScript ES6 Arrow Functions(箭头函数)
1. 介绍 第一眼看到ES6新增加的 arrow function 时,感觉非常像 lambda 表达式. 那么arrow function是干什么的呢?可以看作为匿名函数的简写方式. 如: var ...
- ES6学习笔记<二>arrow functions 箭头函数、template string、destructuring
接着上一篇的说. arrow functions 箭头函数 => 更便捷的函数声明 document.getElementById("click_1").onclick = ...
- ES6 箭头函数(Arrow Functions)
ES6 箭头函数(Arrow Functions) ES6 可以使用 "箭头"(=>)定义函数,注意是函数,不要使用这种方式定义类(构造器). 一.语法 具有一个参数的简单函 ...
- Arrow functions and the ‘this’ keyword
原文:https://medium.freecodecamp.org/learn-es6-the-dope-way-part-ii-arrow-functions-and-the-this-keywo ...
- js in depth: arrow function & prototype & this & constructor
js in depth: arrow function & prototype & this & constructor https://developer.mozilla.o ...
- ES6箭头函数(Arrow Functions)
ES6可以使用“箭头”(=>)定义函数,注意是函数,不要使用这种方式定义类(构造器). 一.语法 1. 具有一个参数的简单函数 var single = a => a single('he ...
- 深入浅出ES6(七):箭头函数 Arrow Functions
作者 Jason Orendorff github主页 https://github.com/jorendorff 箭头符号在JavaScript诞生时就已经存在,当初第一个JavaScript教 ...
- JS ES6中的箭头函数(Arrow Functions)使用
转载这篇ES6的箭头函数方便自己查阅. ES6可以使用“箭头”(=>)定义函数,注意是函数,不要使用这种方式定义类(构造器). 一.语法 基础语法 (参数1, 参数2, …, 参数N) => ...
随机推荐
- MT【286】最佳有理逼近
2017北大优秀中学生夏令营已知$\omega $是整系数方程$x^2+ax+b=0$的一个无理数根, 求证:存在常数$C$,使得对任意互质的正整数$p,q$都有$$|\omega-\dfrac{p} ...
- Vert.x系列(三)--ClusteredEventBus源码分析
前言:因为ClusteredEventBus涉及集群,有必产生网络问题,从而引入了NetServer.ServerID等涉及网络,端口的类.在之前的EventBusImpl中, 使用的数据结构是以ad ...
- 网络文件系统(NFS)简介
网络文件系统(Network File System, NFS)是一种分布式文件系统协议,最初由Sun Microsystems公司开发,并于1984年发布.其功能旨在允许客户端主机可以像访问本地存储 ...
- Entity Framework 问题集锦
作者:疯吻IT 出处:http://fengwenit.cnblogs.com 1. No Entity Framework provider found for the ADO.NET provid ...
- LOJ#6277. 数列分块入门 1
分块思想,先把原来的序列分成根号n快,然后对于更新的部分,先操作这个序列边上的部分,然后再中间部分整块操作,这样复杂度就是O(根号N) #include<map> #include< ...
- centos7下kafka集群安装部署
应用摘要: Apache kafka是由Apache软件基金会开发的一个开源流处理平台,由Scala和Java编写.Kafka是一种高吞吐量的 分布式发布订阅消息系统,是消息中间件的一种,用于构建实时 ...
- nodejs的某些api~(五) HTTP模块
HTTP的模块是nodejs最重要的模块(应该是),最近在看HTTP权威指南,重新过了一遍http协议和web客户端.再来看这个http. HTTP构建于TCP之上,属于应用层协议,继承自tcp服务器 ...
- Flask 应用上下文
应用上下文(application context) 它的字面意思是 应用上下文,但它不是一直存在的,它只是request context 中的一个对 app 的代理(人),所谓local proxy ...
- Linux:不同文件相同列字符合并文件(awk函数)
存在file1.txt,其内容如下: H aa 0 0 1 -9 H bb 0 0 2 -9 H cc 0 0 2 -9 存在file2.txt,其内容如下: H aa 0 0 0 -9 asd qw ...
- redis设置密码以及jedisPool设置密码
转: redis设置密码以及jedisPool设置密码 2019年01月02日 20:24:43 宇文荒雪 阅读数:1118 版权声明:本文为博主原创文章,未经博主允许不得转载. https:// ...