ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Excellent Javascript Reference

<< < (2/3) > >>

housetier:
The re-introduction was quite informative! Thanks for the hint.

ewemoa:
Thank you for sharing in your original post!

(Tangential note: I just noticed how the Douglas Crockford videos were mentioned in the "Additional Resources" section of  "Essential Javascript -- A Javascript Tutorial".  From watching some of those videos I was under the impression that "getElementByID" is incorrect while "getElementById" is correct -- I see both on the "Essential..." page.  I guess that one is really easy to get wrong.)

ewemoa:
FWIW, I think the following from the "re-introduction" may be mistaken:

JavaScript distinguishes between null, which is an object of type 'object' that indicates a deliberate non-value, and undefined, which is an object of type 'undefined' that indicates an uninitialized value — that is, a value hasn't even been assigned yet.

--- End quote ---

From the ECMA 262 Standard:

4.3.9 Undefined Value

    The undefined value is a primitive value used when a variable has not been assigned a value.

4.3.10 Undefined Type

    The type Undefined has exactly one value, called undefined.

4.3.11 Null Value

    The null value is a primitive value that represents the null, empty, or non-existent reference.

4.3.12 Null Type

    The type Null has exactly one value, called null.

--- End quote ---

Perhaps the text in the re-introduction is a result of the weirdness (broken-ness?) of the typeof operator.  According to:

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/typeof_Operator

typeof returns "undefined" for values (there's only one as I understand it - undefined) of type Undefined but it returns "object" (!!) for values (again only one - null) of type Null.

On a related note, I came across the following at:

http://javascript.crockford.com/recommend.html

typeOf

The typeof prefix operator returns a string based on the type of its parameter. Unfortunately, it provides the wrong result if the operand is null or an array.

The new typeOf global function is intended to replace the defective typeof operator. It produces the same result as typeof, except that it returns 'null' for null and 'array' for arrays.

It can be implemented in JavaScript:

function typeOf(value) {
    var s = typeof value;
    if (s === 'object') {
        if (value) {
            if (typeof value.length === 'number' &&
                    !(value.propertyIsEnumerable('length')) &&
                    typeof value.splice === 'function') {             
                s = 'array';
            }
        } else {
            s = 'null';
        }
    }
    return s;
}

--- End quote ---

ewemoa:
I also came across the following today and so far am finding it to be pretty good too:

http://www.jgharris.demon.co.uk/jsfeats/JSfeats.html

Although I'm not sure about the following bit:

In outline, each object is a collection of properties. Each property has a name and a value. The value can be any member of any of the javascript types.

--- End quote ---

I've been under the impression that the value portion of a property can not have the value of undefined -- as I understand it, undefined is what is returned if one attempts to access a non-existent property.

Edit: this impression seems faulty -- at least testing under Firebug using Mozilla, it looks possible for a property's value to have the value of undefined.  Time for hasOwnProperty() and possibly additional code perhaps...

Edit 2: I think I know where I picked up my initial impression -- I think it may have been in the first video of Douglas Crockford's series "The JavaScript Programming Language" -- specifically, there is a slide titled "Dynamic Objects" which contains some text: "A name can be any string, a value can be any value except undefined"

ewemoa:
A Crockford piece of an overview nature:

  http://javascript.crockford.com/survey.html

FWIW, I'm finding a combination of the following to be quite helpful in developing my understanding of JavaScript:


* reading more than one of these overviews (and on more than one occasion)
* dipping into ECMA 262 for clarification
* use of Firebug to test/verify code samples
Edit: I should add one more item to the list: at least one concrete project to test ideas out on -- in my case FARR plugins via ecaradec's FScript (plus examining czb's myriad plugins) has been quite informative.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version