JavaScript

Javascript is a dynamic and lightweight programming language common used as part of web pages.


I wll provide some javascript examples that you can incorporate into your apps or website.
Introduction sample
    
var a = 5; //Number
var b = 6; //Number
var c = "Titus" //String
var d = ["James","John"] //Array
var e = {fname:"Titus",lname:"Tom",age:5} //object
var f = true //boolean
var g = null
var h = function(p1,p2){ return p1+p2 } //function
//Arithmetic
alert(a+b) // 11
alert(a*b) // 30
alert(a/b) // calculate?
alert(b&a) // 1

//Comparison
alert(a<b) //true
alert(a>b) //false
alert(a==b) //false
alert(false==false) //true
alert(true==false) //false
alert(true==true) //true

//Logical
alert(a||b) //5
alert(b||a) //6
alert(a&&b) //6
alert(b&&a) //5
alert(false||true) //true
alert(false&&true) //false

//Array
alert(d[0]) //James
alert(d[2]) //John

//String 
alert(c+c) //TitusTitus
alert(c-c) //Error:not a number

//object
alert(f.fname) //Titus
alert(f.age) //5

//Function
alert(h(2,3)) //5
alert(h("cat","dog")) //catdog

Categories
External
Contact

Free Web Hosting