jguerra[at}northeastern.edu | @duto_guerra
Slides:http://johnguerra.co/lectures/webDevelopment_spring2025/05_Javascript/
Class page:http://johnguerra.co/classes/webDevelopment_spring_2025/
function add5(a) {
return a + 5
}
const add5_anon = function(a) {
return a + 5
}
const add5_arrow = (a) => {
return a + 5
}
function showHelp(help) {
document.getElementById("help").textContent = help;
}
function setupHelp() {
var helpText = [
{ id: "email", help: "Your email address" },
{ id: "name", help: "Your full name" },
{ id: "age", help: "Your age (you must be over 16)" },
];
for (var i = 0; i < helpText.length; i++) {
// Culprit is the use of `var` on this line
var item = helpText[i];
document.getElementById(item.id).onfocus = function () {
showHelp(item.help);
};
}
}
setupHelp();
console.log(x === undefined); // true
var x = 3;
(function () {
console.log(x); // undefined
var x = "local value";
})();
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_Types#Variable_hoisting
Build a listings page from the SF Airbnb listings for Sept 2023 JSON file.