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的更多相关文章

  1. 《理解 ES6》阅读整理:函数(Functions)(四)Arrow Functions

    箭头函数(Arrow Functions) 就像名字所说那样,箭头函数使用箭头(=>)来定义函数.与传统函数相比,箭头函数在多个地方表现不一样. 箭头函数语法(Arrow Function Sy ...

  2. JavaScript ES6 Arrow Functions(箭头函数)

    1. 介绍 第一眼看到ES6新增加的 arrow function 时,感觉非常像 lambda 表达式. 那么arrow function是干什么的呢?可以看作为匿名函数的简写方式. 如: var ...

  3. ES6学习笔记<二>arrow functions 箭头函数、template string、destructuring

    接着上一篇的说. arrow functions 箭头函数 => 更便捷的函数声明 document.getElementById("click_1").onclick = ...

  4. ES6 箭头函数(Arrow Functions)

    ES6 箭头函数(Arrow Functions) ES6 可以使用 "箭头"(=>)定义函数,注意是函数,不要使用这种方式定义类(构造器). 一.语法 具有一个参数的简单函 ...

  5. Arrow functions and the ‘this’ keyword

    原文:https://medium.freecodecamp.org/learn-es6-the-dope-way-part-ii-arrow-functions-and-the-this-keywo ...

  6. js in depth: arrow function & prototype & this & constructor

    js in depth: arrow function & prototype & this & constructor https://developer.mozilla.o ...

  7. ES6箭头函数(Arrow Functions)

    ES6可以使用“箭头”(=>)定义函数,注意是函数,不要使用这种方式定义类(构造器). 一.语法 1. 具有一个参数的简单函数 var single = a => a single('he ...

  8. 深入浅出ES6(七):箭头函数 Arrow Functions

    作者 Jason Orendorff  github主页  https://github.com/jorendorff 箭头符号在JavaScript诞生时就已经存在,当初第一个JavaScript教 ...

  9. JS ES6中的箭头函数(Arrow Functions)使用

    转载这篇ES6的箭头函数方便自己查阅. ES6可以使用“箭头”(=>)定义函数,注意是函数,不要使用这种方式定义类(构造器). 一.语法 基础语法 (参数1, 参数2, …, 参数N) => ...

随机推荐

  1. centos6.8下普通用户下quartus编程识别不到用户开发板

    前言 centos6.8下su用户下可以识别到用户的板子,能正常下板,而普通用户下无法探测到用户板子. 需要配置一下usb-blaster,不然的话,虽然quartus软件能识别,但是无法探测到FPG ...

  2. opencv 图片剪切

    import cv2 as cv import numpy as np # 图片剪切 img = cv.imread('../images/moon.jpg', flags=1) # flags=1读 ...

  3. Python35安装

    wnm系列之python安装 下载网址https://www.python.org/downloads/ 之前就用的3.5.4版本,这次还下这个 安装,我直接选择的install now 默认位置安装 ...

  4. Android assets的一个bug

    摘要 Android assets目录下资源文件超过1MB的问题. 由于要显示一些奇奇怪怪的日文字符,我们在应用里放了一个字库文件,譬如叫做jp.ttf,放在assets目录下打包. 开发.调试一切正 ...

  5. nginx.conf(centos7 1.14)主配置文件修改

    #nginx1.14 centos7# For more information on configuration, see:# * Official English Documentation: h ...

  6. 关于Autosar中DCM(14229UDS)模块的理解

    阅读本篇文章希望达到的目的是: UDS是干什么的, ISO14229是如何定义规则的, 希望接下来的阅读让你不虚此行. 1. UDS是干什么的?UDS全称是Unified Diagnostic Ser ...

  7. 20165223 Linux安装及命令入门

    预备作业3:Linux安装及命令入门 一.VirtualBox和Ubuntu的安装 通过学习实践基于VirtualBox虚拟机安装Ubuntu图文教程,我开始学习虚拟机的安装,根据教程一步步试着安装. ...

  8. Educational Codeforces Round 46 C - Covered Points Count

    C - Covered Points Count emmm 好像是先离散化一下 注意 R需要+1 这样可以确定端点 emmm 扫描线?瞎搞一下? #include<bits/stdc++.h&g ...

  9. 如何刻录cd音乐

    用nero,选择cd,音乐光盘(第一个)可以添加入wav,MP3等.刻录即可.

  10. jQuery ajax读取本地json文件

    jQuery ajax读取本地json文件 json文件 { "first":[ {"name":"张三","sex": ...