📅  最后修改于: 2022-03-11 15:01:25.081000             🧑  作者: Mango
function weekdayText(weekdays) {
return function getText(target) {
return weekdays[target] || (function() {
throw new Error(`Invalid weekday numer ${target}`)
}());
}
}
daysInWeek = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
getText = weekdayText(daysInWeek)
console.log(getText(5))