Duration: 17 minutes
Summary: In this video we discussed variable scope. When we declare a variable in JavaScript we use the keyword var. In this way, if we declare the variable in a function the scope of the variable in the function itself. In other words, the variable cannot be seen outside the function. But there is another way of using variables: we do not need to use the keyword ‘var’ (for example x = 5). When we declare a variable this way, the scope of this variable is the whole document. We see an example where the same variable is accessed in the header, body and the ‘MyFunctions.js’ file. It is NOT recommended to use global variables. I just showed them to you in this video so you know they exist and if you are looking at someone else’s code who is using them. We also looked at how to use events (such as mouse clicks and loading document). Finally, we looked at how to obfuscate your code so other developers will not be able to copy it and use it when they ‘view source’.
Methodology of the development of example: Good coding standard and simplified design.
Technology Used: JavaScript – Core language Concepts
Keywords: CSS, JavaScript, HTML, function, var, script, document, writeln, obfuscate, scope, onload.