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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint