Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
Constants in javascript are somewhat new, but otherwise the synthax is: const ANSWER = 42; Another way to do it (from Burke at StackOverflow): var CONFIG = (function() { var private = { 'MY_CONST': 'foo', 'ANOTHER_CONST': 'bar' }; return { get: function(name) { return private[name]; } }; })(); alert(CONFIG.get('MY_CONST')); alert(CONFIG.get('ANOTHER_CONST'));
8th Sep 2016, 8:00 AM
Zen
Zen - avatar