问题标签 [variable-declaration]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1773 浏览

javascript - 在 Javascript 中使用 var 和 this 有什么区别?

这些有什么区别?

0 投票
5 回答
968 浏览

c - Why does this C code compile?

I'm defining an integer variable called c, and I'm assigning its value to itself. But how can this even compile? c hasn't been initialized, so how can its value be assigned to itself? When I run the program, I get c is 0.

I am assuming that the compiler is generating assembly code that is assigning space for the the c variable (when the compiler encounters the int c statement). Then it takes whatever junk value is in that un-initialized space and assigns it back to c. Is this what's happening?

0 投票
6 回答
1574 浏览

c# - 变量声明是否应该始终放在循环之外?

在循环外而不是在循环内声明在循环中使用的变量是否更好?有时我会看到在循环内声明变量的示例。这是否有效地导致程序在每次循环运行时为新变量分配内存?或者.NET 是否足够聪明,可以知道它实际上是同一个变量。

例如,从这个答案中查看下面的代码。

这个修改后的版本会更有效吗?

0 投票
5 回答
187480 浏览

vba - 我可以同时在 VBA 中声明和分配一个变量吗?

我是 VBA 新手,想知道是否可以将以下声明和赋值转换为一行:

或者

0 投票
4 回答
251 浏览

c# - 在子块中声明变量会提高性能吗?

在 C# 中,比较以下三种替代方案时,性能会有什么不同吗?

0 投票
18 回答
6821 浏览

c# - 在变量声明中使用“var”类型

我们的内部审计建议我们使用显式变量类型声明而不是使用关键字var。他们争辩说,使用var“在某些情况下可能会导致意想不到的结果”。

var一旦代码编译为 MSIL,我不知道显式类型声明和使用 of 之间有什么区别。

审计师是一位受人尊敬的专业人士,所以我不能简单地拒绝这样的建议。

0 投票
4 回答
30423 浏览

variables - Lisp 中的 setq 和 defvar

我看到Practical Common Lisp用于(defvar *db* nil)设置全局变量。不是可以setq用于相同的目的吗?

使用defvarvs.的优点/缺点是setq什么?

0 投票
1 回答
2014 浏览

sql-server - 在 sql server 2005 中创建变量并指定排序规则时出现错误

当我尝试这个时:

收到:

那是完整的代码,它可以工作,我不知道如何,但是给我的人已经成功使用它

0 投票
2 回答
9637 浏览

vba - Excel-VBA:需要变量声明吗?

如果写如下代码会不会出错

没有明确声明每个变量?如下所示;

0 投票
7 回答
568 浏览

python - 像 Python 这样易于学习的语言,但需要变量声明?

Python 超级容易学习和理解;我喜欢它,因为它使用了关键字、缺乏复杂的语法(与 perl 相反,据我所知)以及易于使用的数据结构。但是,我无法忍受缺少变量声明,因为它无法明确告诉 Python 您希望变量具有什么作用域。是否有任何语言具有我喜欢 Python 的所有品质以及变量声明,也许还有一组不错的库可用?

谢谢。