HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <p>Objects can store any types of data, including functions. Such function properties are called object methods. The method call is written like this: object.method().</p>
1 <p>Objects can store any types of data, including functions. Such function properties are called object methods. The method call is written like this: object.method().</p>
2 <p>From within methods, you can access properties and other methods of an object using the this keyword. It points to the current object and is called a <em>call context</em>.</p>
2 <p>From within methods, you can access properties and other methods of an object using the this keyword. It points to the current object and is called a <em>call context</em>.</p>
3 <p>Important detail: until the function is called, this does not contain any value; the context appears only when the function is called.</p>
3 <p>Important detail: until the function is called, this does not contain any value; the context appears only when the function is called.</p>
4 var cat = { name: 'Muffin', color: 'red', age: 5, getGreeting: function () { return 'Meow, hello! My name is ' + and this.name; } }; console.log (cat.getGreeting()); // Logs 'Meow, hello! My name is Muffin'<p>Maps or dictionaries are very convenient to use. In our example, they store the relationship of the name of the cat and his favorite delicacy.</p>
4 var cat = { name: 'Muffin', color: 'red', age: 5, getGreeting: function () { return 'Meow, hello! My name is ' + and this.name; } }; console.log (cat.getGreeting()); // Logs 'Meow, hello! My name is Muffin'<p>Maps or dictionaries are very convenient to use. In our example, they store the relationship of the name of the cat and his favorite delicacy.</p>
5 var catsFavoriteFood = { Muffin: 'fish', Rudolph: 'cutlet', Snowball: 'milk' }; var printFavoriteFood = function (name) { // Using bracket notation return 'My favorite food is ' + catsFavoriteFood[name]; }; console.log(printFavoriteFood('Snowball')); // Logs 'My favorite food is milk'<a>Continue</a>
5 var catsFavoriteFood = { Muffin: 'fish', Rudolph: 'cutlet', Snowball: 'milk' }; var printFavoriteFood = function (name) { // Using bracket notation return 'My favorite food is ' + catsFavoriteFood[name]; }; console.log(printFavoriteFood('Snowball')); // Logs 'My favorite food is milk'<a>Continue</a>