What happens if reduce is called with no parameter?

Hello everyone,

I have a humble question to ask.
Problem: function isArray(value) return boolean of whether argument is an Array object or not

function isArray(value) {
return (value.length >= 0 && typeof(value) == ‘object’);
}

This is my way, and it works since isArray([‘a’, ‘b’, ‘c’] return true and isArray(5) return false

and this is another solution, and I am not clear on this

function isArray(value) {
return Boolean(value.reduce);
}

I would like to know what value.reduce will return. Could anyone please help me out this question? Thanks

The second function is testing if the provided argument has inherited the built-in arrayreduce method.
Then proceed to convert it to a boolean.

If you are curious to know what happens when you access a method instead of calling it
(ie)

[].map
// instead of
[].map()

all you have to do is open up your browser console and type it.
In this case my browser is telling me that a method called reduce exists since it returns a function

[].reduce
// f reduce() { [native code] }

Hope this helps :+1: