Skip to content

Instantly share code, notes, and snippets.

@ACbosong

ACbosong/.js Secret

Created August 10, 2021 10:37
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 ACbosong/243662c7a70c7d445599056c961d10c9 to your computer and use it in GitHub Desktop.
Save ACbosong/243662c7a70c7d445599056c961d10c9 to your computer and use it in GitHub Desktop.
// 這個示例來自You Don't Know JS: https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/apA.md#var-and-let
function getStudents() {
try {
// not really a block scope
var records = fromCache("students");
}
catch (err) {
// oops, fall back to a default
var records = [];
}
// ..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment