I have a JS code like it:
const supportedRegions = ['usa', 'brazil']
const isSupportedRegion = region => supportedRegions.includes(region)
isSupportedRegion('brazil') // true
And it works fine. But if I wrote something like, returns an unexpected error:
const supportedRegions = ['usa', 'brazil']
const isSupportedRegion = supportedRegions.includes
isSupportedRegion('brazil') // error: Uncaught TypeError: Cannot convert undefined or null to object at includes (<anonymous>) at <anonymous>:1:1
Why it is saying that can't convert from undefined
or null
?? The variable isSupportedRegion
is a function!
typeof isSupportedRegion // "function"
isSupportedRegion // ƒ includes() { [native code] }
Someone could explain what is happens, please?