MDanz Posted February 9, 2010 Share Posted February 9, 2010 is it possible to do... if (javascript function) ?? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted February 9, 2010 Share Posted February 9, 2010 yes Quote Link to comment Share on other sites More sharing options...
MDanz Posted February 9, 2010 Author Share Posted February 9, 2010 how do i do it? i have a javascript function called ChgTxt.. if(ChgTxt) {} lol Quote Link to comment Share on other sites More sharing options...
Adam Posted February 9, 2010 Share Posted February 9, 2010 Use the 'typeof' operator to check it's defined as a function: if (typeof ChgTxt == 'function') { Quote Link to comment Share on other sites More sharing options...
yozyk Posted February 9, 2010 Share Posted February 9, 2010 It is necessary that the function returns the value. Use return operator in function body. Quote Link to comment Share on other sites More sharing options...
Adam Posted February 9, 2010 Share Posted February 9, 2010 It is necessary that the function returns the value. Use return operator in function body. ... What? Quote Link to comment Share on other sites More sharing options...
yozyk Posted February 9, 2010 Share Posted February 9, 2010 function ChgTxt() { // your code return boolValue; } if(ChgTxt) alert('True!') else alert('False!') Quote Link to comment Share on other sites More sharing options...
Adam Posted February 9, 2010 Share Posted February 9, 2010 From the OP I got the impression he wanted to check if the function exists, you may be right. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.