Create a type predicate function that passes if input is one of the given values.
input
values
Values are compared using SameValueZero (like Array.prototype.includes()), so NaN matches NaN and 0 matches -0.
Array.prototype.includes()
NaN
0
-0
const isPrimary = oneOf('red', 'green', 'blue');isPrimary('red'); // trueisPrimary('yellow'); // false Copy
const isPrimary = oneOf('red', 'green', 'blue');isPrimary('red'); // trueisPrimary('yellow'); // false
Create a type predicate function that passes if
inputis one of the givenvalues.Values are compared using SameValueZero (like
Array.prototype.includes()), soNaNmatchesNaNand0matches-0.