Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 71 - 2609_Logicode
P. 71

    </BODY>

                     </HTML>
                     The output of the preceding HTML code is as follows:

                               OUTPUT STATEMENT IN JAVASCRIPT

                     In JavaScript, output statements display information to the user or developer. There are various
                     methods suited to different purposes, including debugging with the developer console, interacting
                     with the user via pop-up dialogs or directly changing the content of a web page.

                     Different ways to display output in JavaScript are as follows:

                       document.write(): The document.write() method writes directly to the HTML document.
                       It’s usually used for simple output during the loading of the page, but it can overwrite the entire
                       document if used after the page has loaded.
                       For example,

                       document.write("JavaScript is versatile and widely used.");

                       document.write("It creates interactive web pages.");
                       The output of the given code is:
                       JavaScript is versatile and widely used. It creates interactive web pages.

                       console.log(): The  console.log() method  is  used  to  display  messages  or data  in the
                       browser’s console (Developer Tools). It’s commonly used for debugging.
                       For example,

                       let message = "Hello, World!";
                       console.log(message);

                       The output of the given code is:
                       Hello, World!

                               COMPONENTS OF A JAVASCRIPT STATEMENT

                     The components  of a JavaScript  statement  include  expressions,  variables, operators  and
                     keywords, which work together to carry out a particular task.

                                                                                               JavaScript for Beginners  69

| 66 67 68 69 70 71 72 73 74 75 76 |