— Inlining is the matter of optimizing compiler, you may make a hint but you dont control it.
— I know, but there is nothing to inline in these examples
— I'll post the code I used
—
'use strict';
let sum = 0;
console.time('loop');
for (let i = 0; i < 100000000; ++i) {
sum += i;
}
console.log(sum);
console.timeEnd('loop');
Message permanent page
—
'use strict';
const sum = (i, acc) =>
i < 100000000
? sum(i + 1, i + acc)
: acc;
console.time('ptc');
console.log(sum(0, 0));
console.timeEnd('ptc');
Message permanent page
— Definitly, it will be inlined
— It will be transformed into loop
— Yes, but that's not what function inlining is