spacer
Yehuda Shiran March 6, 2001
JavaScript's Object Types
Tips: March 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

JavaScript supports three types of objects: native, host, and user-defined. Native objects are objects supplied by the JavaScript language. 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);
  }
}


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger