Skip to content

Instantly share code, notes, and snippets.

@LinZap
Created June 9, 2019 09:39
Show Gist options
  • Save LinZap/e072a371005c9aa6284a6667361bd02e to your computer and use it in GitHub Desktop.
Save LinZap/e072a371005c9aa6284a6667361bd02e to your computer and use it in GitHub Desktop.
Node.js - HK5
let width = 200;
function delayPrintWidth(ms) {
let w = width
setTimeout(() => console.log(w), ms)
}
delayPrintWidth(1000); // 預期印 200
width = 300;
delayPrintWidth(2000); // 預期印 300
width = 400;
delayPrintWidth(3000); // 預期印 400
200
300
400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment