JavaScript Output code

To output content in JavaScript, you can use the following methods:

  1. alert() method: This method creates a pop-up dialog box that displays the specified message and waits for the user to click the OK button.
    alert('Hello, world!');
    ​
  2. console.log() method: This method logs the specified message to the browser's console. This is useful for debugging purposes.
    console.log('Hello, world!');
    ​
  3. document.write() method: This method writes the specified message directly to the HTML page. Note that this method should be used with caution, as it can overwrite the entire page if used after the page has loaded.
    document.write('Hello, world!');
    ​
  4. innerHTML property: This property sets or returns the HTML content (inner HTML) of an element. This can be used to dynamically update the content of a webpage.
    document.getElementById('myDiv').innerHTML = 'Hello, world!';
    ​

Note that in order to see the output of these methods, you will need to run the JavaScript code in a web browser or a JavaScript console.

Related Articles

- All From ChatGPT
PLG_GSPEECH_SPEECH_BLOCK_TITLE