We're a place where coders share, stay up-to-date and grow their careers.
Niche thing:
There is no point in structures like this:
function example (string) { if (string.test(/./gu)) { return true; } return false; }
String.prototype.test already returns a boolean, so is almost like saying:
String.prototype.test
boolean
"if x is true then return true, if not then return false"
x
true
false
Instead of just returning x. This is far better:
const example = string => string.test(/./gu);
Niche thing:
There is no point in structures like this:
String.prototype.test
already returns aboolean
, so is almost like saying:Instead of just returning
x
. This is far better: