Skip to content

Instantly share code, notes, and snippets.

@ACbosong

ACbosong/.js Secret

Created August 10, 2021 10:36
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/3613d8b350e1d8ed2e138ad1b887658c to your computer and use it in GitHub Desktop.
Save ACbosong/3613d8b350e1d8ed2e138ad1b887658c 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(data) {
var studentRecords = [];
for (let record of data.records) {
let id = `student-${ record.id }`;
studentRecords.push({
id,
record.name
});
}
return studentRecords;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment