This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)
Given the code
function subMatches(string, subs) { | |
return [] | |
.concat.apply([], subs.map(sub => matchIndexes(string, sub))) | |
.reduce((acc, idx) => { | |
acc[idx] = true; | |
return acc; | |
}, Array.from(string).fill(false)); | |
} | |
function matchIndexes(string, sub, startIndex=0, matches=[]) { |
iex> i 'hello'
Term