To access the write method we use the dot operator (i.e. also known as the member access operator)
The content passed to the write method is also known as a parameter or argument.
To the write method, we can pass a single value or an expression i.e. single argument.
Ex: document.write(2); document.write("Hello World");
To the write method, we can pass multiple values separated by commas i.e multiple arguments.
Ex: document.write(2+2); document.write("2"+"2"); document.write(2, 2); document.write("2", "2");
- () parentheses are evaluated inner most to outer most+
- operators are evaluated form left to right.
- , comma separators are evaluated from left to right.
let name= "HELLO WORLD "; document.write(name); /* Output: HELLO WORLD */
In the above, the let is a datatype and “name” is a variable. Then we assign the value “HELLO WORLD” to a variable name. And using document.write a method to print the variable “name”. So, the output comes “HELLO WORLD”.