const songs = [
{ name: "Film 1", duration: 300, released: 1990 },
{ name: "Film 2", duration: 400, released: 1995 }
]
const shortestReducer = (prev, next) => prev.duration < next.duration ? prev : next
const shortest = songs.reduce(shortestReducer, songs)
Miałbym pytanie jakim argumentem jest tutaj songs w metodzie reduce:
const shortest = songs.reduce(shortestReducer, songs)
Według dokumentacji metoda reduce przyjmuje takie argumenty:
array.reduce(function(total, currentValue, currentIndex, arr), initialValue)
Czy w takim razie argument songs jest tutaj jako initialValue przekazany?