Javascript is_scalar : Variable handling : PHP functions in JavaScript JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » PHP functions in JavaScript » Variable handling »

 

Javascript is_scalar


Returns true if value is a scalar
Example 1

Running
1.is_scalar(186.31);

Could return
1.true
Example 2

Running
1.is_scalar({0: 'Kevin van Zonneveld'});

Could return
1.false
function is_scalar( mixed_var ) {
    // Returns true if value is a scalar  
    // 
    // version: 812.1017
    // discuss at: http://phpjs.org/functions/is_scalar
    // +   original by: Paulo Ricardo F. Santos
    // *     example 1: is_scalar(186.31);
    // *     returns 1: true
    // *     example 2: is_scalar({0: 'Kevin van Zonneveld'});
    // *     returns 2: false
    return /boolean|number|string/.test(typeof mixed_var);
}


HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo PHP functions in JavaScript
» Variable handling