I think some snippets could be simplified, shouldnt they?
I'm kind of newbie on js, but i would do this: IsNumeric: function(s){ isNaN(s) ? false : true }, IOr like this, function(s){ return !isNaN(s) } 2007/3/13, Karl Rudd <[EMAIL PROTECTED]>:
The ! operator does a "binary invert", returning either "true" or "false". So: true == !false false == !true So: false == !!false true == !!true Combine that with what JavaScript considers "false" and you end up with something like this: // Test to see whether something is "null" or 0 (zero) or "undefined" or "false" var something = doSomething(); if ( !something ) doSomethingElse(); Anything that is NOT "null" or 0 (zero) or "undefined" or "false", is considered "true". Going back to the "!!s[k]". The problem is that the value of s[k] might not be a boolean "true" or "false", so we need to convert it to one. So we "!" it first and that converts it to a boolean, though if it was a "true" value it's now "false", and vice-versa. So we "!" it again and it comes out the "correct" way. Karl Rudd On 3/14/07, Daemach <[EMAIL PROTECTED]> wrote: > > What does the !! do? > > > Dan G. Switzer, II wrote: > > > >>Please add: > >> > >> StructKeyExists: function(s,k){ > >> for(var n in s){ > >> if (n == k) return true; > >> } > >> return false; > >> }, > >> > >> > >>Shall we post additions and updates here? > > > > This would be much more efficient: > > > > StructKeyExists: function(s,k){ > > return !!s[k]; > > }, > > > > However, it's also important to remember that a ColdFusion "structure" > > isn't > > the exact same thing as a JavaScript Object. > > > > -Dan > > > > > > _______________________________________________ > > jQuery mailing list > > discuss@jquery.com > > http://jquery.com/discuss/ > > > > > > -- > View this message in context: http://www.nabble.com/NEW-Plug-in%3A-cfjs-%28ColdFusionJavaScript%29-tf3386950.html#a9465975 > Sent from the JQuery mailing list archive at Nabble.com. > > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
-- Rafael Santos Sá :: webdeveloper www.rafael-santos.com
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/