Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 107 - CodePilot V5.0 C8
P. 107

    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.
                     Understanding  the components  of a JavaScript statement  is essential  for  writing functional
                     code and building interactive web applications.

                                                                                                                      105
                                                                                                JavaScript for Beginners

| 102 103 104 105 106 107 108 109 110 111 112 |