Web Development · Notes
Fri, 08 May 2026 11:42:49 GMT
JavaScript closure
function outside(x) {
function inside(y) {
return x + y;
};
return inside;
}
fn_inside = outside(5);
result = fn_inside(3); // 8
result = fn_inside(5); // 10
result = fn_inside(8); // 13
function makeCounter() {
let count = 0;
return function() {
return count++;
};
}
let counter1 = makeCounter();
let counter2 = makeCounter();
alert(counter1()); // 0
alert(counter1()); // 1
alert(counter2()); // 0 (independent)
Fri, 08 May 2026 11:40:29 GMT
Git repository
Create a new repository on the command line
echo "# test-repo" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/brettkromkamp/test-repo.git
git push -u origin main
…or push an existing repository from the command line
git remote add origin https://github.com/brettkromkamp/test-repo.git
git branch -M main
git push -u origin main