Posts

"Master JavaScript Objects: A Complete Beginner-to-Expert Guide"

Unlocking the Power of JavaScript Objects:  A Comprehensive Guide In JavaScript, an object is a non-primitive data type that is used to store collections of data and more complex entities. Objects are a cornerstone of JavaScript and understanding them is key to mastering the language. 1. What is an Object? An object is a collection of key-value pairs , where the keys are called properties or methods : A property is a key associated with a value. A method is a function associated with an object. JavaScript Code-                  const person = {      name: "John",       age: 30,      greet: function () {               console.log ("Hello, " + this. name);   } }; 2. Creating Objects a. Object Literal The simplest and most common way to create an object is using curly braces {} . JavaScript Code-       const car = {   ...

'this' Keyword JavaScript Notes

Image
                                        'this' keyword JavaScript Notes                 'this' keyword works differently in different Scope.         'this' in global Scope          console . log ( this )         output-          Window {window: Window, self: Window, document: document, name: '', location: Location, …}        'this' in strict and non-strict mode           'this' keyword works differently in strict and non-strict mode.                 "use strict"          function x(){          console.log(this);         }          x();            ...