Question:

document.write("Hello Students"); which of the following is a method in the given JavaScript statement?

Show Hint

In JavaScript, a method is a function attached to an object, such as document.write() or console.log().
  • write
  • document
  • Hello
  • Students
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

Step 1: Understand JavaScript objects and methods.

In JavaScript, objects contain properties and methods. A method is a function that belongs to an object and performs a specific action.

The statement given in the question is:

document.write("Hello Students");
Here, document is an object representing the HTML document, and write() is a method associated with that object.

Step 2: Explain how the method works.

The write() method is used to display text directly on a web page. When the browser executes the JavaScript code, the text inside the parentheses is written into the HTML document.

Example:

document.write("Welcome to JavaScript");
This will display the message on the webpage.

Step 3: Analyze other parts of the statement.

document: This is an object representing the webpage.

Hello and Students: These are simply words inside the string that will be displayed as text.

They are not JavaScript methods.

Step 4: Conclusion.

Therefore, the method used in the given statement is write().
Was this answer helpful?
0
0