They should do the same, but there is a better way.
Theoretically, the second, assigning only if the value is false, can eliminate the assignment and be faster. Indeed, in jsperf we see that it is (12%).
In fact, the explicit if statement executes as quickly as the then-assign condition:
if(!options) options = {};
Try the test on your browser / machine .
I think it is explicit, if it is most clear, and has no punishment.
Edit:
If you expect the object to be passed to a function , I think the best test is:
if(typeof options !== 'object') options = {};
This ensures that you have the object later, even if it is empty. Any other test (for undefined or false) will allow a true non-object through a non-zero number or non-empty string. However, as jsperf shows, this is ~ 15% slower. Since you only do this when entering a function that will process objects, I would say that this is a useful compromise, and a little slower than always assigned .
source share