Anton Kosykh
1 min readSep 11, 2018

--

Hi. Nice article!

But, in the “Filter and Map” example, if performance matters, better use .push() instead of .concat(). It won’t create a new array on each tick:

const smartestStudents = studentsData.reduce(
(result, student) => {
if (student.score <= 80) {
return result;
}
// Better
result.push(`${student.firstName} ${student.lastName}`)
return result
},
[]
);

Also, in the “Array to Object conversion” example, you can get rid of extra spread:

// Your
{ ...rules, ...{ [field.name]: field.constraints } }
// The same
{ ...rules, [field.name]: field.constraints }

Good luck!

--

--

Anton Kosykh
Anton Kosykh

Written by Anton Kosykh

— Stricty pants nerd that sounds like total dork (according to one of the readers) — Also YOLO JavaScript Engineer

Responses (1)