CopyAndPaste

random programming notes

Javascript Function Optional Arguments

Simple example:

1
2
3
4
function foo(a, /* optional */ b) {
  b = b || []; // returns b if b is defined and non-null, 
               // even if b is empty.
}