JavaScript for Programmers [old]

Part 1: Sensitizing with JavaScript language

function main() {
return
‘Hello, World!’;
}

main(); ->>return’s ‘undefined’

Part 2: JavaScript Basic Development Guidelines

var MyModuleName = (function(){

//module variable; this will be returned; see below

var my ={};

//private variables

var map=null;

var maploaded=false;

var markersArray = new Object();

//private methods

var panToSelection = function(sitename){

var cachedsite = markersArray[sitename];

if(!cachedsite){

console.log(“Site no in map yet”);

return;

}

map.panTo(cachedsite.latlong);

};

//public method/s

//Getting the browser width and height

var getbrowserWidthandheight= function(){

var winW = 630, winH = 460;

if (document.body && document.body.offsetWidth) {

winW = document.body.offsetWidth;

winH = document.body.offsetHeight;

}

if (document.compatMode == ‘CSS1Compat’ && document.documentElement &&

document.documentElement.offsetWidth) {

winW = document.documentElement.offsetWidth;

winH = document.documentElement.offsetHeight;

}

if (window.innerWidth && window.innerHeight) {

winW = window.innerWidth;

winH = window.innerHeight;

}

return {winHeight:winH,winWidth:winW};

};

//Associate methods that you want to be visbile outside the module , public methods to the object that you return from this

my.getbrowserWidthandheight =getbrowserWidthandheight; //public methods

return my;

})(MyModuleName );

Invoke from Another JS /JSP or HTML

MyModuleName.getbrowserWidthandheight();

>>Result example output → Object { winHeight : 513 , winWidth : 1218 }

var TTT= TTT || {} ; //check if the variable with name TTT exists. If not, create a new variable with empty value

TTT.Abc= TTT.Abc|| {};

TTT.Abc.statusTable = TTT.Abc.statusTable || {};

//Declaring a global function.

TTT.Abc.statusTable.setId = function(id) {

TTT.Yyy.Page.id = id;

}

Part 3: JavaScript Advanced Development Guidelines (optional)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store