Monday, 22 February 2016

Javascript - Programs Basic

Javascript Programs
In a programming language, computer program instructions are called statements.
JavaScript is a programming language and JavaScript statements are separated by semicolons.

Example:
var a = 1;
var b = 2;
var c = a + b;

And next is the javascript statements, and it includes 

  • values
  • operators
  • expressions
  • keywords and 
  • comments

JS Values:
JS values are two types, literals (fixed values) and variables

Numbers - 10.50,100
String - with single or double quote"name"

Variables:
Variables are used to store data values. JS uses var keyword to assign variables.
Eg: 
var x;
x=10;

Operators:
JS uses an assignment operator ( = ) to assign values to variables: 
var a=90;
JS uses arithmetic operators ( + - *  / ) to compute values: 
a * 10 (expressions)
also in string level
 "Mark" + " " + "Layer", evaluates to "Mark Layer":

Comments:
Code after double slashes // or between /* and */ is treated as a comment.Comments are ignored, and will not be executed:

Eg:
var a = 50;   // I will be executed

// var a = 50;   I will NOT be executed

JS Statements:
JS statement tells the browser to write "I am in." inside an HTML element with id="example":
Example:
document.getElementById("example").innerHTML = "I am in.";

One program example:

var a = 5;
var b = 6;
var c = a + b;
document.getElementById("example").innerHTML = c;


3 comments :

  1. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates…
    Regards

    SAP Training in Chennai

    ReplyDelete


  2. EXcellent posts..

    sap fiori training in hyderabad

    ReplyDelete
  3. In my search for online SAP training, I bumped into www.call4training.com. Highly recommend this course to anyone struggling with understanding of SAP Basis.
    SAP Hana training in hyderabad

    ReplyDelete