Hi All!
I want to thank both David and Lasse for your input to this thread. Here
is the result of my thinking now - once again I welcome further comments
or criticisms.
============
Here are two ways to think about JavaScript objects.
1) The first is in terms of typical object oriented concepts. An object
encapsulates.
- data (called properties in JavaScript); and
- behaviour (called methods in JavaScript).
This way of thinking is useful because it enables a discussion of
objects in a non-language specific manner.
2) The second way to think about JavaScript objects involves us
understanding that in JavaScript, a function is also an object.
JavaScript objects have properties that we can refer to by name.
Each property has a value.
A Javascript value is either:
- a primitive (number, string, boolean, undefined or null); or
- an object (function or non-function).
This way of thinking is useful because it helps us to understand that a
JavaScript object definition (i.e. a class in object oriented
terminology) is any function that assigns itself properties.
Further concepts.
A prototype is an object property that belongs to a constructor function
and is automatically created when the function begins assigning
properties to itself. The prototype is JavaScript's way of remembering
what properties an object definition has. Object definitions (i.e.
constructor functions) may inherit or copy the prototype of other object
definitions - meaning that a constructor may define itself as having the
same set of properties as another constructor.
A var is a local variable. A local variable is a value that may only be
referenced by code within a function or script, depending on whether the
var was declared within a function or script respectively.
============
Rob
:)
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!