Lawrence said:
I already stated that the Shelly Powers book is full of factually false
statements.
An earlier post you made discussed "opinions" in books published by
O'Reilly. As I said in response to that, it is important to distinguish
between facts and opinions.
Facts are things like:-
| In addition to the ECMAScript reserved words, there are
| JavaScript-specific words implemented in most browsers that are
| considered reserved by implementation. Many are based in the
| Browser Object Model--objects such as document and window. Though
| not a definitive list, Table 2-3 includes the more common words.
|
| Table 2-3. Typical reserved words in browsers
| alert eval location open
| array focus math
....
a factual statement regarding reserved words of the "Browser Object Model".
Another fact:-
| Many times, variables and functions have one or more words
| concatenated into a unique identifier, following a format
| popularized in other languages, and frequently referred to as
| /CamelCase/:
|
| validateName
| firstName
|
| This approach makes the varible much more readable, though
| dashes or underscores between the variable "words" works as
| well:
|
| validate-name
| first_name
another factual statement, this time regarding syntax, not reserved words.
That statement is followed by:-
| Though you can use $, number, or underscore to begin a variable, your
| best bet is to start with a letter.
That is two pages of Shelly Powers. Practically every page is loaded
with stuff like that.
| Null and Undefined.
| The division between literals, simple data types, and objects
| is blurred in JavaScript, nowhere more so then when looking at two
| that represent nonexistannce or incomplete existance: null and
| undefined.
|
| A /null/ variable is one that has been defined but hasn't been
| assigned a value. The following is an example of a null variable:
|
| alert(sValue); //results in JavaScript error because sValue is
| // (wrapped) not declared first.
On the proceeding page, she provides advice for how to handle this
problem when using several JS libraries:-
| When using several JS libraries and fairly complex code, it's not
| unusual for a variable to not get set, and trying to use it in an
| expression can have adverse effects -- usually a JavaScript error. One
| approach to test variables if you're unsure of their state is to use
| the variable in a conditional test, such as the following:
|
| if(sValue) ... // if not null and initialized, expression is true;
| // (wrapped) otherwise false.
|
| We'll look at conditional statements in the next chapter, but the
| expression consisting of just the variable sValue evaluates to |true|
| if sValue has been declared and initialized; otherwise, the result of
| the expression is false.
|
| if (sValue) // not true, as variable has not been declared, and
| // (wrapped) is therefore null
|
| var sValue;
| if (sValue) // variable is not null, but it's still not true, as
| // (wrapped) variable has not been defined (initialized with a value)
|
| var sValue = 1;
|
| if(sValue) // true now, as the variable has been set, which
| automatically declares it.
|
Opinions, OTOH, expresses personal or unproven belief.
For example:-
| No doubt no one should write a line of code, even in a light weight
| scripting language, until they have completed their Ph.d in computer
| science at Stanford, yet in the real world, people often do write code
| before their Ph.d is complete.
- could be considered your opinion and would serve as an example of
"opinion" in the general sense.
Another meaning of opinion applies to professional expert advice. (My
doctor's opinion, the judge's opinion, etc). I don't see how that would
be relevant here; Shelly Powers is not an authoritative expert.
Garrett