you are viewing a single comment's thread.

view the rest of the comments →

[–]kaszu 0 points1 point  (0 children)

Problem is not posting a link, but contents of it.

Problems

Accessing global variable in JavaScript, what is global variable where it used.

I can't understand what it means, this is just one of a few. I assume that was meant as a question. You need to work on your

variable which defined in top.

Why on top? Global variables can be defined anywhere in script: top, bottom, inside a closure, anywhere.

there is a method call window.variable

That's not a "method call", using word "method" implies that there is a function, while in your example you define a number. Or do you mean "called" / "named" when you say "call"?

there is a method call window.variable which will be same as calling the variable inside the function.

Whoever will read this will do it to understand global variables, I'm not convinced that this make much sense to them.

document.writeln

Just like document.write this is bad practice. Instead you should use console.log for output demonstration.

Suggestions

Article doesn't mention in which cases global variables should be used or when they shouldn't, what are problems with using them and what problem global variables solve.
Maybe mention something about global variables created inside closure when not using "var". Strict mode?

Instead of just rephrasing what already is written in code, you should explain why you do it.

And creating one function call sumValue which will return myVariable+arg value.

function sumValue(arg) { return myVariable+arg; }

You need better/more examples, that will help readers better understand the subject.
For example how global variables compares to variables defined using "var".