printf() in C language,
cout in C++, etc.
Using Alert Box
By logging on the Console
We will cover all these with the help of examples. Also, don't worry if you don't understand the syntax for these, we will be covering these in details in upcoming tutorials.
document.getElementById(id) method, where id is the value of the
id attribute of the HTML tag.
Let's take an example, in this example,
id attribute is used to identify the HTML element and
innerHTML property is used to set content to it.
document.write() method. By using this method you can directly write output to the HTML page.
Let's take an example, in this example, we are using
document.write() method which is used to write to the webpage directly.
Let's take an example, in this example, we are using the alert box to write a message and show to the user.
The function used for console logging is
console.log(SOME-EXPRESSION-OR-STRING) which can be used to log anything in the browser's console.
To open developer's tools in the Chrome browser, press F12 in Windows and Command + Option + I in MacOS. The picture below shows how it looks: