I was reading the Three.js code when a silly question arose: Is there any difference between the codes below?
frameHeight = frameHeight !== undefined ? frameHeight : 24;
and
frameHeight = frameHeight || 24;
(frameHeight is a parameter of the function)
Thanks
Yes, they are different.
This will coerce
frameHeightto a boolean value. If it is0,'',false,null,undefined, orNaNit will be false andframeHeightwill be defaulted to 24.This will explicitly check if
frameHeightis notundefinedand ONLY forundefinedwill it default it to24.