/**
@func
if the num is nil, then return a default num instead
@param {number} def - default num to return if n is nil
@param {number} n - expected to be a num; if not, then return the default num
@return {number} - the original n or default num
*/constgetNumOrDefault=(def,n)=>isNil(n)?def:n;
Good tip Maxime.
If one is using pure JavaScript, one can do:
usage:
Thanks for the additional tip - is
isNil
coming from lodash?I have a post here on the isNil func:
dev.to/functional_js/null-vs-undef...