Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fValidate updated

    Pretty much what it says on the tin, really.

    www.peterbailey.net/fValidate/
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #2
    Regular Coder
    Join Date
    Sep 2003
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The first few lines in core...
    Code:
    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.


  • #3
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #4
    Regular Coder
    Join Date
    Sep 2003
    Posts
    290
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And it falls nowhere in scope -- it's in the global namespace
    Indeed. 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.
    Code:
    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.

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by beetle; 10-11-2003 at 07:26 PM.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •