var DYN_WEB = DYN_WEB || {};
I saw above code in one js file
Question:
what does this mean?
var DYN_WEB = DYN_WEB || {};
I saw above code in one js file
Question:
what does this mean?
if DYN_WEB is not null it will take the value already set for DYN_WEB else assign an empty object to it.
This is shorthand for
if ( ! DYN_WEB ) {
DYN_WEB = {}
}
or
var DYN_WEB = DYN_WEB ? DYN_WEB : {}
it means if the variable DYN_WEB
has a value which is evaluated to binary true, then keep that value, otherewise assign {}
to it. The latter will happen if the previous value of the variable is 'falsy' ie. one of the false, null, undefined, NaN, 0, "", []
or {}
and in case it's not defined.