Friday, August 21, 2020

Outputting strings in JAScript

For android projects
There are many ways to output a string in JAScript. The following are some of the ways you can display a string:-

    1. print();
    2. System.out.println()
    3. alert();
    4. 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

JavaScript Syntax

Whitespace and new lines JavaScript ignores spaces, tabs, and newlines that appear in JavaScript code. You are free to fo...