101 reputation
1
bio website google.se
location Sweden
age 27
visits member for 1 year, 4 months
seen Apr 11 '13 at 20:15

Tests:

> false === (0.1 + 0.2 === 0.3)
> true  === (~(-1) === 0)
> true  === (~~(1.999) === 1)
> true  === (5 % 5 === 0)
> true  === (!0 === true)
> true  === (!1 === false)
> true  === (1 == true)
> false === (2 == true)
> false === ([] == [])
> true  === ([] == false)
> false === ([] === false)

typeof:

function getType(s, t) {
    if ( s == null ) {
        t = String(s);
    }
    else {
        t = {}.toString.call(s).slice(8, -1).toLowerCase();
    }
    return t;
}

Tests:

> "object"    === getType({})
> "array"     === getType([])
> "string"    === getType("abc")
> "number"    === getType(123)
> "date"      === getType(new Date())
> "regexp"    === getType(/[0-9]/g)
> "function"  === getType(function() {})
> "string"    === getType(String("abc"))
> "number"    === getType(Number("123"))
> "null"      === getType(null)
> "undefined" === getType(undefined)
> "boolean"   === getType(false)


This user has not answered any questions
This user has not asked any questions
This user has not participated in any tags

0 Votes Cast

This user has not cast any votes