简体   繁体   中英

Why assigning a variable to itself memory=memory?

I am currently analysing some javascript shell-code. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM