Difference Between console.dir and console.log Last Updated : 14 Oct, 2024 Comments Improve Suggest changes Like Article Like Report Console ObjectThe Console object provides access to the browser's debugging console, which can be seen using F12 or ctrl+shift+j. Console object contains many methods, log() and dir() are the most used among them. Console.log:The console.log() method prints out a toString representation of the object in the console to the user. Syntax:console.log(object) or console.log("string", object)Console.dir: The console.dir() method output the list of object properties of a specified object in the console to the user. Syntax:console.dir(object)In simple words, the console.log() returns the object in its string representation and console.dir() recognizes the object just as an object and outputs its properties. Both log() and dir() returns the string just as a string. Example: javascript let str = "Howdy GeeksforGeeks"; let geek = { book: "harrypotter", price: "2000" }; let geek2 = [10, 20, 30]; console.log(str); console.dir(str); console.dir(geek); console.log("geek (log) = ", geek); console.dir(geek2); console.log("geek2 (log) = ", geek2); // Prints only string as dir() takes // only one parameter. console.dir("geek2 (dir) = ", geek2); Output:In the code above, console.log() prints the toString representation of the object, while console.dir() recognizes the object and displays its properties. When run in Chrome, console.log() outputs a tree structure along with the string information. However, in Firefox, console.log() only shows the toString representation, while console.dir() behaves consistently across browsers. For example, when you run console.dir("geek2 (dir) =", geek2);, it only displays the string part because console.dir() takes only one parameter, treating the string as the sole argument, whereas console.log() can accept multiple parameters. Comment More infoAdvertise with us Next Article Difference Between console.dir and console.log T Tejashwi5 Follow Improve Article Tags : Difference Between JavaScript Web Technologies JavaScript-Questions Web Technologies - Difference Between +1 More Similar Reads Difference between Console.Read and Console.ReadLine in C# In C#, to take input from the standard input device, the following method are used - Console.Read() and Console.ReadLine() method. Console is a predefined class of System namespace. While Read() and ReadLine() both are the Console Class methods. The only difference between the Read() and ReadLine() 2 min read Difference between Console.Write and Console.WriteLine in C# In C#, to print the data on the console output screen the following method are used - Console.Write() and Console.WriteLine() method. Console is a predefined class of System namespace. While Write() and WriteLine() both are the Console Class methods. The only difference between the Write() and Write 1 min read Difference Between console.time and console.timeEnd in JavaScript In JavaScript, console.time and console.timeEnd are powerful tools used for performance measurement. These methods allow developers to measure the time a block of code takes to execute, which is particularly useful for optimizing performance and debugging.Table of ContentWhat is console. time?What i 2 min read Difference Between alert and console.log in JavaScript In JavaScript, alert and console.log are two commonly used methods for the displaying information to the user or the developer. While both the serve the purpose of the outputting data they have different use cases and characteristics. This article explores the differences between the alert and conso 3 min read Difference between Terminal, Console, Shell, and Command Line Terminal, Console, Shell, and Command line all are ways to give the command to the computer but all these have different functions. A terminal is a text-based interface that is used to type commands or take input and view the output. A console is a type of terminal that is used to interact with oper 5 min read Like