HighDots Forums  

A couple language questions

Javascript JavaScript language (comp.lang.javascript)


Discuss A couple language questions in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ken Kast
 
Posts: n/a

Default A couple language questions - 07-03-2003 , 11:12 AM






1) I want to test for the existence of a method o.m(), so I tried the line
if (o.m) ...
but the interpreter objects to the missing parentheses on m. (This is in
IE.) What is an appropriate approach for checking the existing of a
function?

2) I've got the following code
window.onresize = function {
....
f();
}
function f() {
....
}
<BODY onload="f();">

My question: if the resize event happens while f is executing, is the first
call to f (onload) flushed from the stack? If not, where in f is execution
resumed after the second call to f takes place in response to the resize
event?

Thanks.

Ken



Reply With Quote
  #2  
Old   
Janwillem Borleffs
 
Posts: n/a

Default Re: A couple language questions - 07-03-2003 , 12:08 PM







"Ken Kast" <knk (AT) kenkast (DOT) com> wrote

Quote:
1) I want to test for the existence of a method o.m(), so I tried the line
if (o.m) ...
but the interpreter objects to the missing parentheses on m. (This is in
IE.) What is an appropriate approach for checking the existing of a
function?

if (typeof o == 'object' && typeof o.m == 'function') {
// Function exists
}

Quote:
2) I've got the following code
window.onresize = function {
...
f();
}
function f() {
...
}
BODY onload="f();"

window.onresize = f; // this is sufficient

Quote:
My question: if the resize event happens while f is executing, is the
first
call to f (onload) flushed from the stack? If not, where in f is
execution
resumed after the second call to f takes place in response to the resize
event?

My guess is that the function will be called twice after the calls have been
queued.


JW





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.