Types

JavaScript is dynamically typed language, that means that type of variable depends from type of its current value.

The typeof operator return a type name of operand. Possible values are name of primitive types or "object" for objects and "function" for the function's names.

The primitive types contain only a single immutable value, and do not have any properties or methods. There are 6 primitive data types: number, bigint, boolean, string, symbol, undefined. They are represent data on low level.

Everything non-primitive are objects. Objects represent complex data with properties and methods. Actually functions also are objects of Function type, although typeof return "function". This is a special case.
The null value also is object for typeof, so be carefully and don't confuse.

The instanceof operator tests whether the prototype property of a specified constructor appears anywhere in the prototype chain of an object.

Functions have property name, that can be used as class name. But be careful if you use the minify code tool, that can change names.

console.log("str", new String("str"), 
    (new String("str")).valueOf());
    
console.log("\ntypeof 'str' is", typeof 'str', 
            "\ntypeof new String('str') is", typeof new String('str'),
            "\ntypeof String is", typeof String,
            "\ntypeof null is", typeof null);
    
function Rect(w=100, h= 100){}
var rect = new Rect();

// expected true, true, false
console.log("rect instanceof Rect: ", rect instanceof Rect);    
console.log("rect instanceof Object: ", rect instanceof Object);    
console.log("rect instanceof String: ", rect instanceof String);

console.log(`class name of type: ${ Rect.name }`);
console.log(`class name of var: ${ rect.constructor.name }`);