Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

simple callback pattern

const add = (a, b, callback) => {
  setTimeout(() => {
    callback(a + b)
  }, 2000)
}

add(2, 3, (sum) => {
  console.log(sum) // should output 5 after 2 seconds
})
Source by gist.github.com #
 
PREVIOUS NEXT
Tagged: #simple #callback #pattern
ADD COMMENT
Topic
Name
4+5 =