View Full Version : fValidate updated

10-11-2003, 11:15 AM
Pretty much what it says on the tin, really.


Jeff Mott
10-11-2003, 06:56 PM
The first few lines in core...
if ( typeof fvalidate == 'undefined' )
var fvalidate = new Object();
}What's this do? If fvalidate is defined, it does nothing. If fvalidate is not defined then it sets the variable fvalidate, which immediately falls out of scope, and so ultimately does nothing.


10-11-2003, 06:59 PM
The global fvalidate object can be created by any of several files -- whichever is loaded first in source order.

And it falls nowhere in scope -- it's in the global namespace.

Jeff Mott
10-11-2003, 07:08 PM
And it falls nowhere in scope -- it's in the global namespaceIndeed. I had to re-read the docs to remember that var only scopes a variable if declared within a function, quite unlike most (if not all) other languages. That was my bad. But how 'bout this one.
Array.prototype.push = function()
var arg, i = 0;
while( arg = arguments[i++] )
this[this.length] = arg;
return this.length;
}What if you wanted to push onto the array the undefined value, null, or even the number 0?

...just keeping you on your toes. :thumbsup:

10-11-2003, 07:14 PM
Yes, I know. but for the purposes of this application, the short-circuit works. Although, I should probably change it anyways.

And you're right -- in JS, braces don't introduce their own scope -- only functions.