0
votes

Is the following a correct classification of the different (main) value types in Javascript?

'use strict';
let
    a = undefined,
    b = false,      
    c = 'hello',
    d = 2.42,
    e = 4,
    f = BigInt(272),
    g = Symbol('a'),
    h = function() {return 'hi'},
    i = null,
    j = /123/,
    k = [1,2,3],
    l = {1: 2};

console.log(`
    // Undefined
    a. ${a} --> ${typeof a}

    // Primitives
    b. ${b} --> ${typeof b}
    c. ${c} --> ${typeof c}
    d. ${d} --> ${typeof d}
    e. ${e} --> ${typeof e}

    // New Primitives
    f. ${f} --> ${typeof f}
    g. ${g.toString()} --> ${typeof g}

    // Function
    h. ${h} --> ${typeof h}

    // Object (everything else)
    i. ${i} --> ${typeof i}
    j. ${j} --> ${typeof j}
    k. ${k} --> ${typeof k}
    k. ${l} --> ${typeof l}
`);

Additionally, it seems very odd to me that the value undefined has type undefined, but then the value null has the type object -- why does the language define it like that?

Why do you expect undefined to have another type?evolutionxbox
I'd say you pretty much covered them all. What exactly is the question?code