+ 2
Is it ok to use print() to output a text in JS ?
Want to know is it ok to use print() and console.log() both to output a data.
3 Antworten
+ 9
JavaScript does not have any print object or print methods. You cannot access output devices from JavaScript.
The only exception is that you can call the window.print() method in the browser to print the content of the current window.
<!DOCTYPE html>
<html>
<body>
<h2>The window.print() Method</h2>
<p>Click the button to print the current page.</p>
<button onclick="window.print()">Print this page</button>
</body>
</html>
+ 8
Seniru Himanjana Devapriya
Javascript doesn't have a print function for output, there are some ways to display or output data.
1. document.write()
2. console.log()
3. windows.alert()
4. Innerhtml() , which is a method for html elements for add, remove and changing its contents
+ 1
The most used function is console.log(), but you can use others (yasin rahnaward writed them)