- Represent real data with JavaScript objects
- Read, update, and add object properties
- Define object methods
- Understand global, function, and block scope
- Compare
var,let, andconst
BMC201 - Web Technology
2026-02-18
Lecture 15
Objects & Scope
Week 4 | Unit II: JavaScript Functions & Events
BMC201 - Web Technology
Mr. Prashant Kumar Nag, Assistant Professor
Learning Objectives
var, let, and constWhat Is an Object?
Objects store key-value pairs:
Think of objects as structured records.
Accessing and Updating Properties
Object Methods
const user = {
firstName: "Aarav",
lastName: "Sharma",
fullName() {
return `${this.firstName} ${this.lastName}`;
}
};
console.log(user.fullName());this refers to the current object in method callsNested Objects and Arrays
Understanding Scope
Scope defines where variables are accessible:
var, let, const Scope
Scope Chain Example
const appName = "WebTech";
function outer() {
const unit = "JavaScript";
function inner() {
console.log(appName, unit);
}
inner();
}
outer();Inner scopes can access outer variables.
Best Practices
const by defaultlet for changing valuesvar in modern codeQuestions?
Next: Lecture 16 - Arrow Functions & Callbacks