Go Back   CodingForums.com > :: Client side development > JavaScript programming > Post a JavaScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-11-2003, 10:15 AM   PM User | #1
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
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”
beetle is offline   Reply With Quote
Old 10-11-2003, 05:56 PM   PM User | #2
Jeff Mott
Regular Coder

 
Join Date: Sep 2003
Posts: 290
Thanks: 0
Thanked 0 Times in 0 Posts
Jeff Mott is an unknown quantity at this point
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.

Jeff Mott is offline   Reply With Quote
Old 10-11-2003, 05:59 PM   PM User | #3
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
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”
beetle is offline   Reply With Quote
Old 10-11-2003, 06:08 PM   PM User | #4
Jeff Mott
Regular Coder

 
Join Date: Sep 2003
Posts: 290
Thanks: 0
Thanked 0 Times in 0 Posts
Jeff Mott is an unknown quantity at this point
Quote:
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.
Jeff Mott is offline   Reply With Quote
Old 10-11-2003, 06:14 PM   PM User | #5
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
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.
__________________
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”

Last edited by beetle; 10-11-2003 at 06:26 PM..
beetle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

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

Forum Jump


All times are GMT +1. The time now is 04:35 PM.


Advertisement
Log in to turn off these ads.