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) => ...
随机推荐
- python的小练习
# -*- coding: utf-8 -*- """练习:有1,2,3,4. 4个数能组成多少个互不相同且无重复数字的三位数,分别是多少?""&qu ...
- [USACO18DEC]Balance Beam
题目链接:这里 或者这里 答案是很显然的,记\(g(i)\)为在\(i\)下平衡木时的期望收益 那么\(g(i)=max(f(i),\frac{g(i-1)+g(i+1)}{2})\) 好了做完了 T ...
- jQuery File Upload 图片上传解决方案兼容IE6+
1.下载:https://github.com/blueimp/jQuery-File-Upload 2.命令: npm install bower install ================= ...
- maven手动安装jar包到本地仓库,以ojdbc6为例
在做mybatis generator的中文注释实现时,感觉每次都要在配置文件中指定ojdbc6的位置太麻烦了,别人用也不方便,没有的还得自己去下,所以就想直接把ojdbc6打包到项目里,这样拿到就可 ...
- 【转】STM32: 一种计算CPU使用率的方法及其实现原理
1 前言出于性能方面的考虑,有的时候,我们希望知道CPU的使用率为多少,进而判断此CPU的负载情况和对于当前运行环境是否足够“胜任”.本文将介绍一种计算CPU占有率的方法以及其实现原理. 2 移植 ...
- 构建DHCP服务
--------------------DHCP 配置-------------------# yum install dhcp -y# vim /etc/dhcp/dhcpd.conf# cp /u ...
- luogu3278/bzoj3323 多项式的运算 (splay)
mulx的操作,其实就是给r+1的系数+=r的系数,然后删掉r,把l~r-1向右移一位,再插一个0到原来的位置 splay维护区间加和区间乘就好了 (一定要注意做事的顺序,一件事都做完了再去做别的,否 ...
- HDU6341 Let Sudoku Rotate (杭电多校4J)
给一个由4*4个4*4的小格组成数独,这些数独是由一个块逆时针旋转得来的,所以要还原的话就模拟出顺时针的过程,先把里面的字母转化成数字,然后从第一个块开始枚举,每个dfs和之前枚举的已经满足条件的块, ...
- Pro Git
1.安装 Linux: $ yum install git $ apt-get install git windows: 打开 http://git-scm.com/download/win,下载会自 ...
- 如何在Windows 10上运行Docker和Kubernetes?
如何在Windows 10上运行Docker和Kubernetes? 在Windows上学习Docker和Kubernetes,开始的时候会让你觉得无从下手.最起码安装好这些软件都不是一件容易的事情. ...