I tried below code in Firefox with Firebug installed.
var t = new Object(); var s1 = new String('str'); var s2 = 'str'; console.log(typeof t); console.log(typeof s1); console.log(typeof s2);
The console output is
object object string
So, <strong>s1</strong> and <strong>s2</strong> are of diffeent type?
Yes, 'str' is a string
literal, not a string
Read up more here.
The process is called boxing/unboxing.
This means that whenever the interpreter/compiler sees a primitive type used as an Object then it will use
to get a valid instance. And in the same way, as soon as you try to use it as a primitive (as in an expression) it will use
to get the primitive.