101 reputation
1
bio website debugger.dk
location Sweden
age 28
visits member for 1 year, 9 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
Stack Overflow 11,981 rep 22660
Meta Stack Exchange 101 rep 2
Webmasters 101 rep 1
English Language & Usage 101 rep 1

0 Votes Cast

This user has not cast any votes