Last Updated : Jan 1, 2023
We sets value to a variable ‘num’ then printed on console using console.log() method for print anything on console panel we need to use this method only otherwise we can’t see any result on console panel.
Here we defined a variable ‘num’ using ‘let’ keyword we can also use ‘var’ keyword instead of ‘let’.
Using that variable we stored ‘45678’ value then printed on console using ‘console.log()’ method.
The console.log() method prints any message that need to be displayed to the user.
It accepts a parameter which can be an array, an object or any message and it returns the value of the parameter given.
<!DOCTYPE html> <html> <head> <title>console log</title> <script> let num=45678; console.log("Number is :"+num); </script> </head> <body> </body> </html>
- <!DOCTYPE html> tag which is instruct the web browser about what version of HTML file written in and it’s not have any ending tag.
- The<html> tag is used to indicate the beginning of HTML document.
- As above shown <head> tag is contains information about webpage and external file links are declared here. <title> tag is used for set the webpage title.
- Both <head> and <title> tags having their pair end tag, so we need to close the ending tags respectively. If you’re not closed anyone of ending tag properly that is also affect the webpage result.
- <body> tag is beginning of main coding part because it contain coding of entire website blocks and elements described here.
- Both </body>,</html> tags closed respectively. </body> tag indicates the end of body, Then </html> tag indicates the end of HTML document.
When we execute our program on browser we can’t see the result so we have use that shortcut ‘ctrl+shift+j’ then result will see printed on console by console.log().