spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com


Developer-Building Trading-Pricing Appl-Capital Markets C#-WPF--WCF-XML-.Net 3.5,ASP, SQL Server
WSI Nationwide, Inc.
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies


Logo

JavaScript Programming: dltypeof() v1.0,
An Introduction


Using dltypeof()

Use dltypeof() whereever you would use typeof().

NOTE

The typeof() operator has two syntax variants:

typeof vExpression
typeof( vExpression )

The dltypeof() function has only one:

dltypeof( vExpression )

Don't forget the parentheses !

JS Objects

All the JS objects that are identified as "object" by typeof() are given more meaningful and obvious identifiers.

The JS Object object has a type of "jsobject" to clearly identify it as a JS object and to differentiate it from any other "object" that dltypeof() may fail to isolate as a unique type.

The JS Function.arguments object is given its own type of "arguments" since it is not a true array.

Any JS object that you create with a constructor function is identified with the name of the constructor function.
For example, let's say you create car objects with the following syntax:

function car( sMake, sModel, nWheels )
{
    this.sMake = sMake;
    this.sModel = sModel;
    this.nWheels = nWheels;
}

var oMerc = new car( "Mercedes", "Grand Sports Tourier", 4 );
var oToy  = new car( "Toyota", "Corolla", 4 );

Then:

dltypeof( oMerc ) returns "car"
dltypeof( oToy )  returns "car"

The following table lists all the possible return values for JS objects as well as the original typeof() return values

JS objecttypeof() return value dltypeof() return value
 
Boolean boolean boolean
Function functionfunction
Number number number
String string string
[ no object ] undefined undefined
 
Argumentsobject arguments
Array object array
Date object date
Error object error
Math object math
Null object null
Object object jsobject
RegExp object regexp
[ custom ] objectCustomConstructorFunctionName


dltypeof() also identifies DOM objects.



Send a comment or suggestion to Peter Belesis

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 >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji

Created: August 23, 2004
Revised: August 23, 2004

URL: http://webreference.com/dhtml/column68/2.html