How to use constant in javascript

Js

Posted on 28 Dec 15 by Vickey
  1360



In javascript we can define constant as below

var constants = {

   'siteUrl': 'test.com',

}; 

you can write all constant in a single file and include this file in your all pages and where we need this constant we can get it by using 

constants.siteUrl;

 


If this post help you reduce time to develop, you can help me to maintain this website :)
www.000webhost.com