var和变量的范围 [英] Scope of var and variables

查看:117
本文介绍了var和变量的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有类似的功能

<cfscript>
function say(what) {
  var a = what;
  variables.b = what;
  return what;
}
</cfscript>

我认为a的范围是变量 ,但转储变量仅返回 b 。一个的范围是什么?

I thought the scope of a was variables, but dumping variables returns just b. What is the scope of a?

推荐答案

使用 var 关键字声明变量会将其放入本地范围,而不是变量范围。

Declaring a variable using the var keyword puts it into the local scope, not the variables scope.

这篇关于var和变量的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆