Consider these two snippets:
Snippet #1
function countDownFn(num) {
if (num === 0) return;
console.log(num);
countDownFn(--num);
}
countDownFn(5); // prints 5, 4, 3, 2, 1 once per line
Snippet #2
var myCounter = function countDownExp(num) {
if (num === 0) return;
console.log(num);
countDownExp(--num);
};
myCounter(5); // prints 5,4,3,2,1 once per line
- Why can I find
window.countDownFn
but cannot findwindow.countDownExp
? - Why would you use one over other?
- Is one of them better than other ? Why?