[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 ...
随机推荐
- Linux的经典shell命令整理
Linux的经典shell命令整理 1.删除0字节文件find -type f -size 0 -exec rm -rf {} \; 2.查看进程按内存从大到小排列ps -e -o “%C : %p ...
- Building Robust and Flexible Event System in Unity3D
Building Robust and Flexible Event System in Unity3D 1. Prerequisites 1.1 Observer Pattern According ...
- python爬取人民币汇率中间价
python爬取人民币汇率中间价,从最权威的网站中国外汇交易中心. 首先找到相关网页,解析链接,这中间需要经验和耐心,在此不多说. 以人民币兑美元的汇率为例(CNY/USD),脚本详情如下: wind ...
- Redis学习与总结
Redis是业界普遍应用的缓存组件,研究一个组件框架,最直观的办法就是从应用方的角度出发,将每个步骤的考虑一番,从这些步骤入手去研究往往能够最快的体会到一个组件框架的设计哲学.以Redis为例,每当发 ...
- SpringBoot学习(六)
1.pom 文件 <?xml version="1.0" encoding="utf-8"?> <dependencies> <d ...
- [QSCOJ39]喵哈哈村的代码传说 第五章 找规律
题目大意: 给你n堆排,两人轮流对其中一堆牌进行以下操作之一: 1.从这堆牌中取出任意数量的牌: 2.将这这堆牌分为任意大小的3堆牌. 不能操作者负. 问先手是否有必胜策略. 思路: 尝试构造sg函数 ...
- php -- 解决php连接sqlserver2005中文乱码问题(附详细解决方法)
@_@~~ --php5.2 --phpstudy --apache --sqlserver2005 @_@~~问题描述 问题一:php连接sqlsever2005,输入中文,然后查询sqlserve ...
- python gensim的第一次试用
参考于 http://blog.csdn.net/xiaoquantouer/article/details/53583980 有一个地方很重要,一定要安装anaconda,安装库简直不要太方便. 先 ...
- maven构建jar包
1.执行可执行的class,代码内需要有入口main方法 2.通过mvn package来构建jar包 3.使用java -jar test.jar来执行jar包 https://www.cnblog ...
- TSearch & TFileSearch Version 2.2 -Boyer-Moore-Horspool search algorithm
unit Searches; (*-----------------------------------------------------------------------------* | Co ...