[Project_owners] Is this valid JS?

Adam Judson adamsplugins at gmail.com
Wed Mar 15 17:55:21 EST 2006


This works though

function ret(message) {
  if (message) {
    throw message;
  }
  return 0;
}

(function f() { var a = false || ret("this is bad code") })()


Can't say I recommend it...

A


On 15/03/06, Nickolay Ponomarev <asqueella at gmail.com> wrote:
> Paul Tomlin wrote:
> >> We could argue about it, but that doesn't lead anywhere. However,
> >> the question he asked still interests me, and I don't know the answer:
> >>
> >> Is the construct shown above correct, and officially supported in
> >> javascript, or is it not?
> >
> > Indeed. I'm tempted to look at the ECMA spec, though it always gives me
> > headaches and never guarantees that it's implemented.
>
> I'll save you some headaches.
>
>  > (function f() { var a = false || return 1 })()
> SyntaxError: syntax error
>
> Nickolay
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>


More information about the Project_owners mailing list