Javascript constant : Miscellaneous Functions : PHP functions in JavaScript JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » PHP functions in JavaScript » Miscellaneous Functions »

 

Javascript constant


Given the name of a constant this function will return the constant's associated value
Example 1

Running
1.constant('IMAGINARY_CONSTANT1');

Could return
1.null
function constant(name) {
    // Given the name of a constant this function will return the constant's associated value  
    // 
    // version: 812.316
    // discuss at: http://phpjs.org/functions/constant
    // +   original by: Paulo Ricardo F. Santos
    // *     example 1: constant('IMAGINARY_CONSTANT1');
    // *     returns 1: null
    if (window[name] === undefined) {
        return null;
    }

    return window[name];
}


HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo PHP functions in JavaScript
» Miscellaneous Functions