Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

namespace 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.
var car = {
    startEngine: function () {
        console.log("Car started");             
    }        
}
  
var bike = {
    startEngine: function () {
        console.log("Bike started");
    }
}
  
car.startEngine();
bike.startEngine();
 
PREVIOUS NEXT
Tagged: #namespace #javascript
ADD COMMENT
Topic
Name
6+4 =