I've seen some code in the form of:
var vendorcode = vendorcode || {};
I've always thought that || was a logical operator. But this one is a real doozy.
I've seen some code in the form of:
var vendorcode = vendorcode || {};
I've always thought that || was a logical operator. But this one is a real doozy.
This code assigns {} to vendorcode if vendorcode is false-y.
Meaning it's undefined, false, 0, null, etc.
If vendorcode is not false-y it'll keep its value.
You can read it out loud as: "vendorcode equals vendorcode OR {}"