Explore the Chrome DevTools console and investigate what the console object stores and how dot notation works.
- Opened Chrome DevTools and navigated to the Console tab.
- Entered
console.logand observed that it returned a function. - Entered
consoleand observed that it returned an object with multiple methods such as log, warn, error, and assert. - Entered
typeof consoleand confirmed that console is an object.
consolestores an object containing many methods used for debugging.console.log,console.assert, etc. are functions stored inside the console object.- The
.operator is called dot notation and is used to access properties or methods of an object.
- https://developer.mozilla.org/en-US/docs/Web/API/Console
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_objects
console.log→ returned a function definition (ƒ log() { [native code] })console→ returned an object with many methods such as log, warn, error, asserttypeof console→ returned "object"
The console variable stores an object that contains multiple debugging methods. These methods allow developers to print messages, warnings, errors, and other diagnostic information in the browser console.
These expressions use dot notation to access methods inside the console object. For example:
console.logaccesses the log functionconsole.assertaccesses the assert function
The dot operator is called dot notation. It is used to access properties or methods of an object.
So:
consoleis the objectlogis a method inside that objectconsole.logmeans "access the log method from the console object"
- Objects store related data and functions together
- The browser console itself is an object
- Dot notation is how we interact with object properties and methods