Skip to content

Instantly share code, notes, and snippets.

@dfkaye
Created August 18, 2024 08:14
Show Gist options
  • Save dfkaye/fd19138a1284a77d6613384e1a6a2572 to your computer and use it in GitHub Desktop.
Save dfkaye/fd19138a1284a77d6613384e1a6a2572 to your computer and use it in GitHub Desktop.
is-number with bigint support
// 22 June 2024
// is-number with bigint support
function isNumber(n) {
var m = typeof n == 'bigint'
? 0n
: 0;
return n - m === Object(n).valueOf();
}
isNumber([1])
//isNumber(new Number(9))
//isNumber()
//isNumber({valueOf: () => 213})
//isNumber(99n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment