MOTOSHARE 🚗🏍️

Rent Bikes & Cars Directly from Owners

Motoshare connects vehicle owners with people who need bikes and cars on rent. Owners earn from idle vehicles, and renters get flexible ride options.

Visit Motoshare

How many ways to Display (Print) data in JavaScript?

JavaScript

Display

• document.write( )
• window.alert( )
• console.log( )
• innerHTML

document.write( )

This function is used to write arbitrary HTML and content into the page. If we use this function after an HTML document is fully loaded, will delete all existing HTML. It is used only for testing purposes.

Ex-

document.write(“Hello World”);
document.write(variable);
document.write(4+2);
document.write(“Hello World.”);
document.write(“Hello World. ” + variable + “ ”);

window.alert( )

This function is used to display data in alert dialog box. alert really should be used only when you truly want to stop everything and let the user know something.

Ex-

window.alert(“Hello World”);
window.alert(variable);
window.alert(4+2);
window.alert(“Hello World” + variable);

console.log( )

This function is used to display data in the console. This is used for debugging purpose. We can identify our code‟s error.

Ex-

console.log(“Hello World”);
console.log(variable);
console.log(4+2);
console.log(“Hello World” + variable);

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x