Horje
namespace in javascript Code Example
namespace in javascript
JavaScript does not provide namespace by default. However, we can replicate 
this functionality by making a global object which can contain all functions 
and variables.

Syntax:
    To initialise an empty namespace
     	var <namespace> = {}; 
    To access variables in the namespace
     	<namespace>.<identifier>
        
Example:
	var car = {
    	startEngine: function () {
        	console.log("Car started");             
    	}        
	}
  
	var bike = {
    	startEngine: function () {
        	console.log("Bike started");
    	}
	}
    
car.startEngine();
bike.startEngine();

Output:
	Car started
	Bike started




Javascript

Related
find a big length friend from array javascript finding longest string in array in javascript Code Example find a big length friend from array javascript finding longest string in array in javascript Code Example
installing ruby version using Rbenv Code Example installing ruby version using Rbenv Code Example
Node-Red Custom UI Code Example Node-Red Custom UI Code Example
only integer allowed javascript Code Example only integer allowed javascript Code Example
How to upper case a string in javascrip Code Example How to upper case a string in javascrip Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8