[ES6] 04. The let keyword -- 2 Fiald case
Fiald case 1: let can work in it's block
{
let a = 10;
var b = 1;
}
a // ReferenceError: a is not defined.
b //
Case 2: Let has no "Hosting" Problem
function do_something() {
console.log(foo); // ReferenceError
let foo = 2;
}
function do_something() {
console.log(foo); //undefined
var foo = 2;
}
//hosting:
function do_something() {
var foo = undefined;
console.log(foo);
foo = 2;
}
Case 3: let不允许在相同作用域内,重复声明同一个变量: In a block, you can only define one variable one time.
// 报错
{
let a = 10;
var a = 1;
} // 报错
{
let a = 10;
let a = 1;
}
But if you do something like:
function f1() {
let n = 5;
if (true) {
let n = 10;
}
console.log(n); //
}
There is no problem! becuase 5 and 10 are in different block scope.
[ES6] 04. The let keyword -- 2 Fiald case的更多相关文章
- [ES6] 03. The let keyword -- 1
var message = "Hi"; { var message = "Bye"; } console.log(message); //Bye The mes ...
- [ES6] 05. The leg keyword -- 3. Block Scope
In ES6, IIFE is not necessary: // IIFE写法 (function () { var tmp = ...; ... }()); // 块级作用域写法 { let tm ...
- ES6 Syntax and Feature Overview
View on GitHub Note: A commonly accepted practice is to use const except in cases of loops and reass ...
- ES6中的数组
数组是js中很重要的数据类型,虽然在 ES5 中,关于数组的方法和属性很多.但为了更加简洁.高效的操作数组,ES6 中又在数组原型上和实例上新增了一些方法. 一.Array方法 1.1 Array.f ...
- Java 8 Features – The ULTIMATE Guide--reference
Now, it is time to gather all the major Java 8 features under one reference post for your reading pl ...
- c# ref 的作用
Usage of ref keyword in C# When we pass a value type variable as a parameter, then it passes its va ...
- 2小时入门Robot Framework
1.介绍 1.1.介绍Robot Robot Framework是一个基于关键字驱动的自动化测试框架.通过该框架,测试人员可使用python封装关键字,并在非代码环境下使用关键字构建可被执行的测试用例 ...
- PHP安全编程:过滤用户输入
如果你能正确可靠地识别和过滤输入,你的工作就基本完成了.最后一步是使用一个命名约定或其它可以帮助你正确和可靠地区分已过滤和被污染数据的方 法.我推荐一个比较简单的命名约定,因为它可以同时用在面向过程和 ...
- ArcGIS API for Silverlight 调用GP服务加载等值线图层
原文:ArcGIS API for Silverlight 调用GP服务加载等值线图层 第二篇.Silverlight客户端调用GP服务 利用ArcGIS API for Silverlight实现G ...
随机推荐
- Vue.js 系列教程 3:Vue
原文:intro-to-vue-3-vue-cli-lifecycle-hooks 译者:nzbin 这是 JavaScript 框架 Vue.js 五篇教程的第三部分.在这一部分,我们将学习 Vue ...
- NumPy简明教程(二、数组1)
NumPy数组 NumPy数组是一个多维数组对象,称为ndarray.其由两部分组成: 实际的数据 描述这些数据的元数据 大部分操作仅针对于元数据,而不改变底层实际的数据. 关于NumPy数组有几点必 ...
- hibernate-release-4.3.11.Final资源包介绍
资源下载 hibernate-release-4.3.11.Final documentation 包 相关文档 lib 相关jar包 required --开发中必须要加入的包 optional ...
- hdu 3642 体积并
题意:求三个矩形体积的并 链接:点我 枚举z #include<stdio.h> #include<iostream> #include<stdlib.h> #in ...
- bzoj 4780: [Usaco2017 Open]Modern Art 2
4780: [Usaco2017 Open]Modern Art 2 Time Limit: 10 Sec Memory Limit: 128 MB Description Having becom ...
- SQL Server 事务复制爬坑记
SQL Server 复制功能折腾了好几天了,现特将其配置过程以及其间遇到的问题记录下来,以备日后查阅.同时,也让“同道”同学们少走不必要的弯路.如果有不对之处,欢迎大家指正,欢迎沟通交流. 一.复制 ...
- [转]Intel haxm安装失败问题解决
在安装Intel haxm为安卓模拟器加速时,会遇到提示VT-X未开启问题,问题提示如下图 工具/原料 Intel haxm 安卓模拟器 方法/步骤 1 确认你的处理器是否是Intel的,如果是AMD ...
- hdu 4114 Disney's FastPass 状压dp
Disney's FastPass Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- hihocoder1489 Legendary Items (微软2017年预科生计划在线编程笔试)
http://hihocoder.com/problemset/problem/1489 笔试题第一道,虽然说第一道都很水,但是我感觉这题不算特别水把..这道题我就卡住了我记得,tle,最后只有30分 ...
- Win8系统108个运行命令 你能记住多少?
Win8运行命令:程序和功能 取消了开始菜单的Win8让人感觉很不习惯,这才发现原来开始菜单可以做这么多事.不过Win8中的一些快捷键还沿用了Windows一直以来的习惯,比如按下Windows ...