First, Felgall, I want to thank you, I will be using your site extensively for a while. And from now on I will always separate my javascript out into a .js file. It makes a lot of sense, why go through so much HTML when editing to find the javascript?
Onto my questions:
Ex. 9
Code:
var name;
name = window.location.search.substring(1);
if ('' === name)
document.getElementById('ex').innerHTML = 'Who are you?';
else
document.getElementById('ex').innerHTML = 'Hello '+name;
So brackets are optional?
Code:
if(true)
{do this;}
else(false)
{do this;}
I'll probably always use them though, the above
is my normal style for one liners, regardless of programming language.....
Another question: I'm used to naming functions like so:
This is how other languages do it, though in some languages the word function is dropped...
I take it that in Ex. 15 on your site you are saying that more proper way to name them this way:
Like is used in the following:
Code:
request.onreadystatechange = function()
Is it absolutely necessary to name functions this way, or is it just a style preference?
Last note: I find your examples just a little hard to read, I generally do not:
Code:
if(true){
do this;
do that;
}
I find it more readable to do:
Code:
if(true)
{
do this;
do that;
}
unless I want to save space:
Code:
if(true){do this; do that;}
This bit I understand is strictly style preference.
Ex.22:I love that we now have .getFullYear for the Date() object...no more need for a Y2K fixer function that is needed for the .getYear method
Is using <!-- and // --> for hiding JavaScript from those browsers that cannot handle it deprecated? Though I would imagine that by pulling the JavaScript out into a .js file makes it unnecessary anyways; and feature sensing makes it unnecessary as well.
Other than general spelling errors, I find your site VERY informative. Thank you for putting it together.
Sorry, didn't feel like this absolutely required a new thread....