Sounds like you have some kind of "JavaScript lint" plug-in installed
(or I think there's also a mode of Firefox that will do that).  It's
not out-of-the-box behavior.  These tools aim to help you find
*possible* errors in your code, but can also flag up things which are
perfectly valid though they may look like coding errors.

I'd suggest finding the plug-in (add-on) or setting that's doing this
and turning it off if you don't care for it.

Specifically, what the lint tool is complaining about is something
like this:

For instance:

    function foo(bar) {
        if (bar) {
            return bar * 2;

Although I would strongly recommend you didn't code things this way,
it's perfectly legal JavaScript whereas in many languages that
wouldn't be valid syntax because "...not all code paths return a
value."  In that example, foo only returns a value if 'bar' is
truthy.  In JavaScript, if a function doesn't return a value, the
expression calling it takes the value undefined as though the function
had returned undefined.  So here:

    var x = foo(false);

...x is undefined, whereas here:

    var x = foo(1);

....x is 2.

For all practical intents and purposes, you can read a function that
doesn't explicitly return anything as having an implicit "return
undefined". (Although technically the spec draws a distinction between
the two situations, in practical terms, it's a distinction without a

Prototype has several functions that these lint tools would look at a
bit askance; this is a fairly common Prototype pattern:

    function someNiftyElementFunction(element) {
        element = $(element);
        if (!element) return;
        // ...nifty stuff here...
        return element;

Again, technically only one of those code paths has a return value,
although in practice it's as though the "return;" were "return
undefined;", and in any case it's valid syntax, just the kind of thing
that *looks* like it might be a programmer error.

T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Aug 10, 12:19 pm, panoramix <jackson92...@gmail.com> wrote:
> Hi,
> I try prototype.js tout retrieve the browser type with if
> (Prototype.Browser.IE) and so on and when i load this page with
> Firefox, i recieve many warnings ex:
> Warning: anonymous function does not always return a value
> Line: 130, Column: 45
> Source Code:
>       case 'boolean': return object.toString();
> Warning: anonymous function does not always return a value
> Line: 133, Column: 32
> Source Code:
>     if (object === null) return 'null';
> Warning: test for equality (==) mistyped as assignment (=)?
> Line: 348, Column: 39
> Source Code:
>       if (match = source.match(pattern)) {
> I don't know if is very important but for your information
> thank's
> panoramix
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to