JackMahoney
JackMahoney

Reputation: 3433

Assignment in function argument list Javascript

Is this valid JS? It runs but was wondering whether that was a browser quirk. I know its probably bad practice as its confusing but still a cool concept.

    showClickMask : function showClickMask(callback){

        (function(mask){
            mask.addClass('open');
            mask.click(function(){RAV.closeClickMask(mask,callback);});
        })(showClickMask.mask = showClickMask.mask || $('#click-mask'));

    },

Upvotes: 0

Views: 187

Answers (1)

RichieHindle
RichieHindle

Reputation: 281725

Yes, that's valid, standards-compliant JavaScript. Assignment is an expression, and "returns" the value being assigned.

(Whether you consider it good style is another question!)

Upvotes: 1

Related Questions