Monday, August 24, 2020

JavaScript Syntax

Whitespace and new lines

JavaScript ignores spaces, tabs, and newlines that appear in JavaScript code. You are free to format and indent your programs in a neat and consistent way that makes the code easy to read and understand.

Semicolons

S tatements in JavaScript generally end with a semicolon character, similar to C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements are placed on a separate line.

  • Example 1

  •       varA  = "Learn"
  •       varB = "JAScript"

  • Example 2

  •       varA  = "Learn" varB = "JAScript"

  • Example 3

  •       varA  = "Learn"; varB = "JAScript";

In the above examples Example 1 and 3 will run while example 2 will generate error.

Case Sensitivity

JavaScript is a case-sensitive language. This means that the language keywords, variables, function names, and any other identifiers must always be typed in consistency.

  • Example 4

  •     var myVar = 5;
  •     var myvar = 10;
  •     print(myVar);
  •     print(myvar);

        Example 5

       function myFunction(){
         return 5;
  • };

  •  function myfunction(){
        return 10;
  • };

In the above example myVar and myvar and two different variables and they will print 5 and 10 respectively. In example 5, the two functions are totally different


Comments in JavaScript

JavaScript supports both C-style and C++-style comments.

    1. Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.
    2. Any text between the characters /* and */ is treated as a comment. This may span multiple lines.

  • Example 6

  • //This is a single line comment
  • var val = 5;
  • var name = "Tree";
  • var combined = val+name;
  • print(combined);
  • /*
  • This
  • is
  • a
  • multiline
  • comment
  • */

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

Thursday, June 18, 2020

JAScript Editor features

The following are some of the features of JAScript Editor
- Syntax highlight for HTML,CSS ,JavaScript and PHP
- Line numbering for easier debugging
- Code folding for easier navigation
- Bookmark line to mark important lines
- Debugger for JavaScript files
- Auto complete variables properties and methods
- Multi tab to help in large projects
- Word wrap to wrap long lines of code
- Show errors as they occurs and highlight them
- Auto fix errors such as missing semicolon
- Format code to make it more readable
- Fix imports of java classes in rhino JS and beanshell
- Search and replace in code
- Fast scroll by dragging a scrollable bar up and down
- Undo Redo when coding
- Jump to specific line in code
- Instant run without compilation
- Resources for learning
- Console to show the output of print() function

How to use JAScript app

Create script
Open the editor, write your code, then click run. After you complete editing click save icon, enter the name of your script then click OK in order to save your script.

Create a project
Click Apps icon then swipe left to open projects tab. Open the menu then click new option, enter the name of your project and click OK. You will be redirected to the editor where you write your code then save. In a project you can add multiple scripts and resources such as images.

Create an app
Long click on a project item, in the popup menu that appears select Build app. Your .jpk app will be saved in the JAScript folder.

Change theme
Go to settings click on App, then click Theme, finally select the color themes provided.

Change editor syntax theme
Open the editor, open menu , select tools, click syntax theme, then select a theme from your storage. After that head to the editor syntax settings and toggle custom syntax highlight on.

Update apps
After update of JAScript app some apps may also be updated, in order to show updated JAScript apps in the Apps tab, open menu then click refresh.

Strict mode
Open settings, click javascript then toggle strict mode on.

Auto fix errors
In the editor open menu select tools then click Fix Some Errors. Currently it only fixes missing ; after satement error. This function works only in strict mode.

Format
Formats codes in a way that makes it more appealing and readable. Ensure first that your code runs in strict mode before performing this action else it might not format properly.

Debugging
You can debug your code line by line by inserting debugger statements in your code. When debugger statement is reached a popup window will appear containing details about the variables with options to exit, step line by line and move to the next debugger statement.

Console
Shows all strings added to logcat with print statement.

Sunday, August 11, 2019

What is JAScript

JAScript is an android app for building apps and games using HTML, CSS and JavaScript. The idea in this app is to help one create an app that caters ones specific needs anytime anywhere with just their phone. JAScript app actively requires only storage permission in order to save scripts and projects. JAScripts apps or scripts you are running in the editor may need additional permissions. This app contains many permissions in order to run wide range of apps. JAScript apps are packaged in a .jpk package which JAScript app on other devices can install. JAScript apps can be converted into standalone android app(apk) which can be installed on any android device.

JavaScript Syntax

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