Good to see you. Killed any more beasts out there?

seen from France
seen from France

seen from United States
seen from United States

seen from China

seen from United Kingdom

seen from Australia

seen from Argentina
seen from United States
seen from United States
seen from United States
seen from Russia
seen from Russia
seen from Senegal
seen from Poland

seen from Russia
seen from Russia
seen from Switzerland
seen from South Korea
seen from Brazil
Good to see you. Killed any more beasts out there?
Default Parameters For Functions In JavaScript
Awhile ago I noticed an interesting feature that would save a lot of time in JavaScript; The ability to set function defaults in a function's parameter definition. At the time the only support was Firefox, but now this has grown to every modern browser (including major mobile ones) except for IE (but has MS Edge support). Here is an example without default parameters:
function formatName(firstName, lastName) { firstName = firstName !== undefined ? firstName : '(none)'; lastName = lastName !== undefined ? lastName : '(none)'; return '(First:Last) ' + firstName + ':' + lastName; } console.log(formatName('Jacob')); // (First:Last) Jacob:(none) console.log(formatName('Super', 'Jacob')); // (First:Last) Super:Jacob console.log(formatName()); // (First:Last) (none):(none)
And here is how default parameters can improve that code:
function formatName2(firstName = '(none)', lastName = '(none)') { return '(First:Last) ' + firstName + ':' + lastName; }
Basically any time an argument is not specified or is undefined, the default is used. Other falsey values like '' do not result in the default being used.
Default parameters can also build on each other if necessary. This is for more specialized cases. I think it is most useful when the second parameter should equal the first by default. Here is how it could simplify a basic isEqual check:
function isEqual(value1, value2 = value1) { return value1 === value2; } console.log(isEqual(2)); // true console.log(isEqual(2, 2)); // true console.log(isEqual(2, 3)); // false
There are a few extra features and some edge cases which can be explained here. Finally, the full compatability list is here.
Github Location: https://github.com/Jacob-Friesen/obscurejs/blob/master/2017/defaultFunctionParameters.js
Node 0, Node 6, Node 13
Well, lad. It's our lucky day after all. I don't feel lucky. The rest of our crew's half-digested, and you're still alive. That's lucky.
Node 9, Node 22, Node 4, Node 11, Node 6
Brem: Did I see you drawing something earlier?
Garias: So? Can do a better job than that ponce you sold.
Brem: Huh. Keep it up, little brother - might be I can sell you some day.
Garias: Aw.
Brem: Like ma always wanted.