История изменений
Исправление Deleted, (текущая версия) :
var a = []; for(var i = 0; i < 10000; i++) {a.push("_" + i + "sadsadsadasdsadasdsa")}
function time(f) {let d = Date.now(); for(var i = 0; i < 1000; ++i){f()}; let res = Date.now() - d; console.debug("Execute ", f.toSource(), " in ", res/1000, "s" )}
time(() => {a.reduce((p, c) => p += c);}); time(() => {a.reduce((p, c) => p + c);})
Execute () => {a.reduce((p, c) => p += c);} in 0.719 s
Execute () => {a.reduce((p, c) => p + c);} in 0.652 s
«что-то»
Исходная версия Deleted, :
var a = []; for(var i = 0; i < 10000; i++) {a.push("_" + i + "sadsadsadasdsadasdsa")}
10000
console.time("one"); a.reduce((p, c) => p + c); console.timeEnd("one");
console.time("two"); a.reduce((p, c) => p += c); console.timeEnd("two");
one: timer started
one: 3.57ms
two: timer started
two: 3.11ms
«что-то»