Skip to content

Instantly share code, notes, and snippets.

@mathdroid
Created December 21, 2020 06:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathdroid/152ef4e5164e285dac4ce94cb5c56c5b to your computer and use it in GitHub Desktop.
Save mathdroid/152ef4e5164e285dac4ce94cb5c56c5b to your computer and use it in GitHub Desktop.
function main(callback1, callback2) {
callback1();
callback2();
callback2();
callback2();
}
function helloWorld() {
console.log("hello world");
}
function helloTelkomsel() {
console.log("hello telkomsel");
}
main(helloWorld, helloTelkomsel);
@mathdroid
Copy link
Author

let array = [20, 21, 22, 23];

let i;

for (i = 0; i < array.length; i++) {
  console.log(i);
  setTimeout(function logElement() {
    console.log("index:", i);
    console.log("element:", array[i]);
  }, 5000);
  console.log("incrementing i");
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment