JavaScript console.log() Method2 Mar 2025 | 3 min read The console.log() method is an essential method in JavaScript. It is utilized to print the output to the console. Syntax:Parameters: The console.log() method takes a parameter which can be any message, an object, array, etc. Return value: It returns a value which is given as a parameter. We can utilize the console.log() method in many ways:
Let us understand each one of them with the help of demonstrations. Giving a message as an argumentIf the message is given to the console.log() method as an argument then the message will be visible to the console. Demo: Output: We can witness the message visible to the console. Welcome to my website Giving a string as an argumentIf the string is given to the console.log() method as an argument then the string will be visible to the console. Demo: Output: We can witness the string to the console. Hello, how are you? Giving a char as an argumentIf the char is given to the console.log() method as an argument then the char will be visible to the console. Demo: Output: We can witness the character on the console. % Giving a number as an argumentIf the number is given to the console.log() method as an argument then the number will be visible to the console. Demo: Output: We can witness the number to the console. 10 Giving a string with the message as an argumentIf the string is given to the console.log() method as an argument then this method will show the string with the message. Demo: Output: We can witness the string with the message to the console. Hi dear, How are you? Giving a number with the message as an argumentIf the number is given to the console.log() method as an argument then this method will show the number with the message. Demo: Output: We can witness the number with a message to the console. The sum of a and b is 15 Giving a char with the message as an argumentIf the char is given to the console.log() method as an argument then this method will show the char with the message. Demo: Output: We can witness the char with a message to the console. The ampersand symbol looks like this: & Giving a function as an argumentIf the function is given to the console.log() method as an argument then this method will show the value of the given function. Demo: Output: We can witness the value of the function to the console. 109 Giving an object as an argumentIf the object is given to the console.log() method as an argument then this method will show the object to the console. Demo: Output: We can witness the object to the console. Giving an array as an argumentIf the array is given to the console.log() method as an argument then this method will demonstrate the array to the console. Demo: Output: We can witness the object to the console. Following are the browsers that support the console.log() method:
Conclusion:We have studied the JavaScript console.log() method in this article. With the help of demonstrations, we have comprehended many ways to utilize the console.log() method. |
In the realm of game development, picking the right engine can have a significant effect between a fruitful task and one that never arrives at its maximum capacity. Web creation has been totally changed by JavaScript, and its flexibility even stretches out to the universe of...
6 min read
Sorting the arrays of objects in JavaScript is a basic manipulation and is also a really important part of programming which is used in day-to-day web development. JavaScript offers two built-in sorting methods: Array.prototype.sort and Array. Sort that both sort the elements in place, but the...
6 min read
What is JavaScript? JavaScript is a scripting language used for both client and server-side development. It enables developers to create interactive web pages. In other words, JavaScript is a text-based method that allows the developer to create dynamically updating content, control the multimedia, or we can animate...
4 min read
Currently, developers work in Visual Studio Code (VS Code) for developing and debugging code purposes because of its rich-feature set, with a large number of extensions and this user-friendly tool. Visual Studio Code can be exactly described as an advanced version of JavaScript - one...
3 min read
The jQuery JavaScript library offers jQuery DataTable, an intelligent and powerful plugin for upgrading HTML tables. It is an extremely adaptable application designed to improve data accessibility in HTML tables by displaying information in tables and adding interactions. jQuery DataTables makes it easy to add sophisticated functionality...
13 min read
This tutorial will teach about the declaration of optional parameters of a function in JavaScript. When a function is defined, it includes certain variables inside its definition to be used within the function block. These are known as function parameters. Note that function parameters need not...
6 min read
? Before starts creating a dropdown list, it is important to know what is a dropdown list. A dropdown list is a toggleable menu that allows the user to choose one option from multiple ones. The options in this list are defined in coding, which is...
6 min read
The JavaScript programming language does not directly support multidimensional arrays. A multidimensional array must be created by employing another one-dimensional array to use something that functions as a multidimensional array. Thus, multidimensional arrays are called arrays inside other arrays in JavaScript. The primary array has the...
7 min read
? What is a New Keyword? In JavaScript, the new keyword is used to create an instance of an object with the use of the constructor method. It means when we create a new instance, JavaScript calls the constructor method every time we create an instance. In simple words,...
5 min read
Both JavaScript and C++ are alent programming languages. JavaScript is a scripting language utilized for web designing whereas C++ is a general-purpose language utilized for low-level system programming. In this article, we will comprehend the difference between JavaScript and C++. Before that, let us understand about...
5 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India