current work
This commit is contained in:
19
5/functioncalledcallback.html
Normal file
19
5/functioncalledcallback.html
Normal file
@ -0,0 +1,19 @@
|
||||
A function with no parameters that prints how many times it’s
|
||||
been called. Hint: define a variable outside of the function to
|
||||
keep track of the number of calls, like we did in the “Side
|
||||
Effects” section on page 77.
|
||||
<html><body><script>
|
||||
let a = 0
|
||||
let b = 0
|
||||
let c = 0
|
||||
|
||||
function calledcallback (){a++;console.log(`calledcallback calls: ${a}`)}
|
||||
|
||||
callback = function () {b++;console.log(`callback calls: ${b}`)}
|
||||
|
||||
cb = () => {c++;console.log(`cb calls: ${c}`)}
|
||||
|
||||
calledcallback()
|
||||
callback()
|
||||
cb()
|
||||
</script></body></html>
|
Reference in New Issue
Block a user