简体   繁体   English

为什么要将变量分配给自身的memory = memory?

[英]Why assigning a variable to itself memory=memory?

I am currently analysing some javascript shell-code. 我目前正在分析一些JavaScript Shell代码。 Here is a line from this script: 这是此脚本的一行:

function having()
{
    memory = memory;
    setTimeout("F0VTp03Y()", 2000);
}

I don't quite understand memory = memory, what's the point of assigning a variable to itself. 我不太了解memory = memory,将变量分配给自己的意义何在? I would appreciate the help! 我将不胜感激!

The only reason I can think of to assign a variable to itself is variable shadowing . 我能想到的给变量本身分配变量的唯一原因是变量阴影

Variable shadowing occurs when a variable declared within a certain scope (decision block, method, or inner class) has the same name as a variable declared in an outer scope. 当在某个范围(决策块,方法或内部类)中声明的变量与在外部范围中声明的变量同名时,将发生变量阴影。 At the level of identifiers (names, rather than variables), this is known as name masking. 在标识符(名称,而不是变量)级别,这称为名称掩码。 This outer variable is said to be shadowed by the inner variable, while the inner identifier is said to mask the outer identifier. 据说此外部变量被内部变量遮盖,而内部标识符则被认为掩盖了外部标识符。 This can lead to confusion, as it may be unclear which variable subsequent uses of the shadowed variable name refer to, which depends on the name resolution rules of the language. 这可能导致混乱,因为可能不清楚阴影变量名称的后续使用是指哪个变量,这取决于语言的名称解析规则。

But in your case, the memory variable is not a parameter of your function so it doesn't make any sense. 但是在您的情况下, memory变量不是函数的参数,因此没有任何意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为全局变量分配新值对内存的影响 - Memory impact of assigning a new value to global variable 为什么在函数外声明变量并在循环中赋值,使用的内存多于局部变量? - Why declaring a variable outside a function and assigning a value in a loop uses more memory than a local var? 在函数中为其分配变量 - Assigning a variable to itself in a function 为什么在Dom对象中为自己分配变量会产生影响 - Why does assigning a variable to itself in a Dom Object make a difference 为变量分配新值会从内存中清除旧值? - Assigning new value to a variable cleans old value from memory? Javascript memory 泄漏:为什么将 object 分配给 Z37A6259CC0C1DAE299A7866489DFFBD0 工作? - Javascript memory leaks: why would assigning object to null work? 用“ null”分配对象会导致内存泄漏吗? - Is assigning an object with `null` creates a memory leak? 在Javascript中为原型分配函数是否有内存性能优势? - Is there a memory performance benefit of assigning a function to the prototype in Javascript? 为什么修改全局变量会增加Chrome中的内存使用量 - Why modifying global variable increases memory usage in Chrome 未初始化的变量内存分配 - Uninitialized variable memory allocation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM