March 6, 2001 - JavaScript's Object Types
March 6, 2001 JavaScript's Object Types Tips: March 2001
Yehuda Shiran, Ph.D.
|
Object
, Math
, and Number
are examples of native objects. Native object names start with a capital letter, and they are case-sensitive. To find the value of the mathematical constant PI, type Math.PI
. If you try math.PI
, you'll get an error message. Host objects are provided by the browser for the purpose of interaction with the loaded document. Examples for host objects are: document
, window
, and frames
. Host object names start with a lower-case letter. You can print on the screen the value of PI by document.write(Math.PI)
. Try Document.write()
and you'll get an error message. You define user-defined objects. You name the objects and you implement them. Your objects can start with either a lower-case letter or an upper-case letter, but they are case-sensitive. Here is an example that gives an error message because of case mismatch (try it):
function employee() {
this.dept = "HR";
this.manager = "John Johnson";
}
function printProp() {
var ken = new Employee();
for (property in ken) {
alert(property);
}
}