The Random Ramblings

lost? dazed? confused? dont come here then as this aint goona help!!

Javascript learning 1

I'm not sure if I was ever told this before on any course or book reading but this is a pretty important thing.

If you declare a variable with out var then it becomes global.

Obviously this can have a huge affect should this not be remembered an example

var myGlobal = 10;

function fun1() {
  // Assign 5 to oopsGlobal Here
  myGlobal = 5;


While you might think that any reference to myGlobal outside of the function would = 10, the setting of myGlobal without var in the function fun1 has now set it to 5.

More posts as I decide I need to remember them.

Find Me
Javascript learning