博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
javascript variable's scope , 变量 范围
阅读量:7074 次
发布时间:2019-06-28

本文共 1000 字,大约阅读时间需要 3 分钟。

hot3.png

Detailed example that writes to this page: 

You can reference all local variables inside the same function the variables are declared.

(L1) local variable declared with var keyword

(L2) local variable declared without var keyword

(L3) local variable declared with var keyword inside if statement

 

You can reference all global variables inside any function.

(G1) global variable declared with var keyword

(G2) global variable without var keyword

(G3) global variable declared with var keyword inside if statement

 

Outside a function, you can only reference local variables that are not declared with the var keyword.

Commented out. Cannot reference (L1)

(L2) local variable declared without var keyword

Commented out. Cannot reference (L3)

 

Outside a function, you can reference all global variables.

(G1) global variable declared with var keyword

(G2) global variable without var keyword

(G3) global variable declared with var keyword inside if statement

转载于:https://my.oschina.net/xiaohelong/blog/366849

你可能感兴趣的文章
PHP设计模式(2)-原型模式
查看>>
lufylegend-HTML5游戏引擎学习笔记6:事件
查看>>
电子邮件加密:PGP 和S/MIME加密的区别
查看>>
esxi嵌套华为Fusioncomputer安装VRM几个关键步骤。
查看>>
PyOpenCL图像处理:两张图片不带权重叠加
查看>>
我的友情链接
查看>>
LAMP架构(PHP5安装,PHP7安装)
查看>>
Cookie与Session的区别
查看>>
比传统事务快10倍?一张图读懂阿里云全局事务服务GTS
查看>>
geowebcache1.14.1配置arcgislayer启动报错的解决
查看>>
关于linux颜色
查看>>
FAQ_Zabbix:解决模板收集到的数据和真实数据有偏差
查看>>
有关游戏外挂的一些思考
查看>>
Bootstrap 介绍
查看>>
Python 的经典设计格言,格言来源于 Python 但不限于 Python
查看>>
python random模块
查看>>
数据流中的中位数(未)
查看>>
利用xss偷cookie教學
查看>>
CentOS 安装过程【图片】
查看>>
深入Hadoop节点部署的策略
查看>>