Are JavaScript variables declared in the body of an if statement scoped to the body?

1) Variables are visible for the whole function scope. Therefore, you should only declare them once. 2) You should not declare the variable twice in your example. I’d recommend declaring the variable at the top of the function, then just setting the value later: function actionPane(state) { var structure; if(state === “ed”) { structure = … Read more

MySQL incrementing value

Yes: Use a user defined variable: SET @position := 0; — Define a variable INSERT INTO products SELECT id_product, id_category, name, (@position := @position + 1) FROM db2.products WHERE id_category = xxx; The result of increment to @position is the value used for the insert. Edit: You can skip the declaration of the variable by … Read more

Removing spaces from a variable input using PowerShell 4.0

The Replace operator means Replace something with something else; do not be confused with removal functionality. Also you should send the result processed by the operator to a variable or to another operator. Neither .Replace(), nor -replace modifies the original variable. To remove all spaces, use ‘Replace any space symbol with empty string‘ $string = … Read more

Dollar sign in variable name

The only legal characters according to the standard are alphanumerics and the underscore. The standard does require that just about anything Unicode considers alphabetic is acceptable (but only as single code-point characters). In practice, implementations offer extensions (i.e. some do accept a $) and restrictions (most don’t accept all of the required Unicode characters). If … Read more

Which variables are initialized when in Delphi?

Global variables are zero-initialized. Variables used in the context of the main begin..end block of a program can be a special case; sometimes they are treated as local variables, particularly for-loop indexers. However, in your example, r is a global variable and allocated from the .bss section of the executable, which the Windows loader ensures … Read more

How can I refresh a stored and snapshotted jquery selector variable

Yeah, it’s a snapshot. Furthermore, removing an element from the page DOM tree isn’t magically going to vanish all references to the element. You can refresh it like so: var a = $(“.elem”); a = $(a.selector); Mini-plugin: $.fn.refresh = function() { return $(this.selector); }; var a = $(“.elem”); a = a.refresh(); This simple solution doesn’t … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)