简体   繁体   中英

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'));

    },

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!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM