A JavaScript Tutorial for beginners

J

John G Harris

Hello Friends

I am new to this group and also new to JavaScript. I have learn
JavaScript from the tutorial which I find good for the beginners and
want to share with you that tutorial.

http://ezdia.com/Javascript_Tutorial/Content.do?id=653

Every page has javascript errors (IE8). Not a good start.

<quote>
"Usually", there is a semicolon at the end of each executable statement.
It is a good programming practise to add a semicolon at the end of the
statement to make it more readable. The semicolon is, however, optional,
and you may find examples without the semicolon at the end.
</quote>

And an even worse continuation. (Hint : it's not true).

And it doesn't improve later on. Not recommended.

John
 
G

Garrett Smith

[link / discussion]
And it doesn't improve later on. Not recommended.
Maybe he removed it.

I see a search box with "Search For", two buttons, two graphics with
"pointer" cursor (hand) that do nothing when clicked. The search box
does not work. Nothing does.

The rest of the page is blank.

FF 3.5 using NoScript.
 
T

Thomas 'PointedEars' Lahn

[Sorry if this is a duplicate, but I don't see this posting on my newsserver
or Google Groups yet.]
I am new to this group and also new to JavaScript. I have learn
JavaScript from the tutorial which I find good for the beginners and
want to share with you that tutorial.

http://ezdia.com/Javascript_Tutorial/Content.do?id=653
..

- JavaScript is misspelled as "Javascript", while neglecting to mention
that there is not one single language, but several different ECMAScript
implementations that are potentially incompatible to one another. Most
notably, Internet Explorer and other MSHTML-based browsers support
JScript, not JavaScript. (Bad start.)

- All the examples there are not Valid markup. (It doesn't get any better.)

- document.write() is a DOM feature, not a language feature; the tutorial
suggests otherwise.

- Section "Browsers that do not support JavaScript" is wrong.

Pseudo-comments have never been really necessary, are outdated if not
obsolete today (HTML 3.2 dates back to 1997-01 and mandates that user
agents ignore the contents of the `script' element if unsupported), and in
XHTML they are even potentially harmful because with an XML parser the
empty commented declaration that it is, is treated just like that (unless
it happens to contain `--' in which case the whole thing is invalid
markup.

`-->' is not a tag; it is the end of an SGML/XML comment in a declaration
followed by the end delimiter of the declaration.

- Section "JavaScript Code":

* Contains three consecutive document.write() calls, which is not only
inefficient but also potentially harmful if adopted as a general
practice because browsers can be unforgiving when writing incomplete
elements.

* The ETAGO delimiters (`</') within the string literal are not escaped
(e.g., as `<\/'), so this code is going to break when used verbatim
within a HTML `script' element (and it will either fail Validation,
or if the newcomer falls for pseudo-comments, the mistake will not
be flagged by the W3C Validator but break in the browser later).

* Disabling single-line comments are used for documentation comments.

- Section "Javascript Variables and Operators":

* See above for invalid markup and pseudo-comments.

* None of the "variables" are declared a variable with the `var' keyword.
This means the global object or a host object in the scope chain is
augmented, with potentially harmful effects (such as in Internet
Explorer when there is an element with the same name or ID).

- Section "Declaring JavaScript Variables", consequently, is wrong, too.
In fact, without the `var' keyword there is no declaration at all.

- Section "Assignment operators" includes an example where `<br />' is
written several times in an *HTML* document, which generates invalid
markup.

The ambiguity of the `+' and `+=' operators is completely ignored there,
but implicit conversion to string when one operand is a string value
has often been observed here to be a source of great confusion among
newbies.

- Section "Comparison Operators" confuses "comparison" with "condition".

Subsection "Conditional Statements" neglects to mention implicit
type conversion to boolean with such statements.

The subsection about the `switch' statement neglects to mention what
happens if the `break' statement is omitted (doing the same for
different cases).

- Sections "Javascript Pop up Boxes", "Javascript Confirm Box", and
"Javascript Prompt Box" are complete nonsense. alert(), confirm(), and
prompt() are methods of Window instances, which are provided by the host
environment (the browser) and are _not_ part of the programming language.
The call should have been window.alert(...), of course.

- Section "For Loop" uses uppercase letters for variables storing primitive
values. However, convention is to use identifiers starting with a
lowercase character for variables, and identifiers starting with an
uppercase letter only for constants (or variables storing primitive values
that should not be changed by a program), constructors and factories.

The use of an argument list of length greater than 1 to write several
values is a proprietary extension to document.write() and recommended
against. The recommendation is to use the `+' operator or a
printf-like approach instead.

The part "We have defined a function which will calculate the area of
the rectangle. Let us take a look at the fuction again." is a copy-paste
error from section "Javascript Functions". A newbie could get the idea
that a loop is a function, which it is not.

- Section "Javascript Functions" goes on to suggest inefficient,
hard-to-maintain nonsense like

var length = new Array();
length[0] = 20;
length[1] = 30;
length[2] = 5;
length[3] = 10;
length[4] = 15;

instead of

var length = new Array(20, 30, 5, 10, 15);

or

var length = [20, 30, 5, 10, 15];

The paragraph

"Functions has slight overhead in loading in execution. In most cases the
gain because of the smaller size of the code as a result of use of
functions outweight the losses due to the overhead. But there may be
instances where it may be otherwise and you may not like to use
functiuons."

makes little sense, if any. A function is loaded (i.e., instantiated)
only once; afterwards it is called. How the internal [[Call]] works is
what makes a function slower than including the code verbatim. The
section also neglects to mention that functions help to avoid globals
which makes code more compatible (is anybody surprised?).

Needless to say that there is no code discipline at all; all variables are
global (except those that were somewhat accidentally declared in the
function), and code is neither indented nor is there a consistent code style.


Here I stopped reading. I am pretty sure that if I continued, I would find
even more of what is listed at
<http://www.mopedepot.com/jjs/HowToRecognizeBadJavascriptCode.html>.

Not only that I cannot recommended this tutorial, I must strongly recommend
against it. Its author(s) clearly does/do not know what they are doing.
 
J

John G Harris

[link / discussion]
And it doesn't improve later on. Not recommended.
Maybe he removed it.

I see a search box with "Search For", two buttons, two graphics with
"pointer" cursor (hand) that do nothing when clicked. The search box
does not work. Nothing does.

The rest of the page is blank.

FF 3.5 using NoScript.

IE8 still shows the text :-(

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top