javascript - Do variables get overwritten -


i have question declaration of variables in javascript , java.

let's in java declare in code variable int x = 6; global variable , along way change x = 10. x variable replace 6 10 permanently? in javascript, lets says have var area = 6 change area = 12 along way global variable, not local, inside function. overwritten permanently?

int 'primitives' in java , javascript, , stored value in variable names them. when change variable's int, value inside of variable directly changed. old value not exist anymore. (we call kind of behaviour value-type)

however, objects different, variables reference objects - , depending on whether object mutable (e.g. java arrays) or immutable (e.g. java strings), operations on object either alter object such every variable referencing sees changes, or create new object changes, such variables referring new object see changes, old object immutable forever.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -