Yep, it would fail because undefined is "falsy".

For more about "falsy" values, have a look here:

http://blog.nydd.org/2008/12/26/falsy-values-%E2%80%9Cjavascript-the-good-parts%E2%80%9D/

On Jan 6, 12:42 pm, "Dave Fliger" <fliger.d...@gmail.com> wrote:
> So the comparison of:
>
> if ( undefined ) {
>
> would fail. Is that correct?
>
>
>
> On Tue, Jan 6, 2009 at 6:31 AM, artemy tregubenko <m...@arty.name> wrote:
>
> > This is ok, because assignment also returns value. What happens here:
> > - seek for a match
> > - if match found, put match data to "match" and go to main branch
> > - if no match found, put undefined to "match" and go to "else"  branch
>
> > On Tue, 06 Jan 2009 15:27:04 +0300, plattecoducks <fliger.d...@gmail.com>
> > wrote:
>
> > > The following looks like a "freshman" error:
>
> > > ln347    while (source.length > 0) {
> > > ln348      if (match = source.match(pattern)) {
> > > ln349        result += source.slice(0, match.index);
> > > ln350        result += String.interpret(replacement(match));
> > > ln351        source  = source.slice(match.index + match[0].length);
> > > ln352      } else {
> > > ln353        result += source, source = '';
> > > ln354      }
> > > ln355    }
>
> > > This comes from the latest download, prototype-1.6.0.3.js. Look at
> > > line 348. This type of code is sprinkled throughout the file.
>
> > > This is an assignment and not a comparison. Thus the statements will
> > > always execute.
>
> > > Can this possibly be correct? Like I said, it looks like a neophyte
> > > error.
>
> > --
> > arty (http://arty.name)
>
> --
> A man has to believe in something; I believe I'll go fishing.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to