DEV Community

Cover image for JAVASCRIPT DISPLAY POSSIBILITIES.
Somtochukwu Nnaji
Somtochukwu Nnaji

Posted on

JAVASCRIPT DISPLAY POSSIBILITIES.

**

WHAT IS JAVASCRIPT DISPLAY POSSIBILITIES ?

**
JavaScript display output or display possibilities is the feasible ways of displaying the output of a given code. Just like in CSS the “display” property when the value is set to “flex” it changes the default display of the container be it inline or block element property.

JavaScript Display Possibilities
The output can be display by using four different ways which are listed below:

  1. innerHTML:
    This method sets or returns the HTML content of an element. You can also say that it is used to access an element.

    <p id="cool">hey</p>
    <script>
    document.getElementById('cool').innerHTML = "Hello world!";
    </script>.

  2. document.write():

    This method is mostly used for testing purpose. it is used to write some content or JavaScript code in a Document. also used to delete all the content from the HTML document and inserts the new content.
    <script>
    document.write('How are you?');
    </script>

  3. window.alert():
    You can use alert box to display data. The alert box is mostly used when you want an information to come through to the user. It is displayed with a message and an OK button.
    <script>
    window.alert("Hello world!")
    alert(" HEY!" )
    </script>

    NOTE: These are both the same syntax.

  4. console.log():
    The console.log() method outputs a message to the web console. The message may be a single string or it may be any one or more JavaScript objects.
    <script>
    console.log(6+3)
    </script>

Top comments (0)