...

View Full Version : object detection - document.getElementById



_com
07-12-2005, 03:33 PM
What to use when, what is the difference??




if(typeof document.getElementById == 'undefined') { return; }



if(!document.getElementById) return;

jbot
07-12-2005, 04:00 PM
there is no difference AFAIK. the latter is shorter and therefore uses less bandwidth.

enumerator
07-12-2005, 06:53 PM
The result is the same, but the difference is type coercion during evaluation due to loose typing.

_com
07-12-2005, 07:53 PM
both could be used for object detection ??


The result is the same, but the difference is type coercion during evaluation due to loose typing.

difference is type coercion??:

eg [found an example -->]For example, the value 0.5 is coercible to the type "32 bit floating point number" but not to the type "32 bit signed integer".

what is meant during evaluation - the javascript parser parsing the script??

loose typing --> have an example ??

enumerator
07-12-2005, 08:11 PM
slow down ;)

Here's an explanation (under the heading Coercion):
http://msdn.microsoft.com/library/en-us/script56/html/js56jscondeclare.asp

Yeah, both can be used: each is an expression which produces the same result of evaluation (true or false). Which one to use is just a matter of preference.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum