There are many ways to output a string in JAScript. The following are some of the ways you can display a string:-
- print();
- System.out.println()
- alert();
- popup()
For HTML Projects
1 document.write()
2 console.log()
3 element.innerText
Examples
Example 1
- var a = "JAScript";
- print(a);
To see the output of the example above open menu, then select console.
Example 2
- var System = Packages.java.lang.System;
- var a = "JAScript";
- System.out.println(a);
Example 2 will also output to console.
Example 3
- var b = "JavaScript";
- alert(b);
Example 3 will show an alert dialog containing the word JavaScript
Example 4
- var c = "Popup";
- popup(c);
Example 4 will show a toast with the content of variable c i.e Popup
No comments:
Post a Comment