Let's start with the basics and add some JavaScript to the webpage.
On the web, JavaScript code resides inside an HTML document, and needs to be enclosed by <script> and </script> :
<> कोड उदाहरण :
Conscious! - You can place the script tag anywhere in it - HTML document.
Output
Let's say "Hello, World!" in the browser. Use Javascript to print. This is what it will look like.
<> Code Example :
document.write() is a function. This is what we need to use to write text in our HTML document.
You can also use standard HTML markup language to customize the appearance text in the output:
<> Code Example :
Conscious! - document.write() should only be used for testing. We'll be covering some other output mechanisms in real soon.
Output To Console
Ok, now we are expert in writing HTML output with document.write().
There are times for a different type of output. Let's learn about the output of the browser console.
For this we will need the reliable console.log() function.
Wait, not so fast! Which console are we talking about?
The console is part of a web browser and allows you to log messages, run JavaScript code, and view errors and warnings.
<> Code Example :
Conscious! - Developers mostly use console for their testing - Javascript code.
Comments