December 2014
Intermediate to advanced
388 pages
8h 1m
English
var str = "Hello";// Assigns a wrapper for str to p1 because str is a primitive typevar p1 = new Object(str);print("p1.valueOf() is", p1.valueOf());print("typeof p1 is", typeof p1);print("p1.valueOf() === str is", p1.valueOf() === str);var msg = new String("Hello");// Assigns the reference of msg to p2. new Object(msg) returns// the reference of msg because msg is an object.var p2 = new Object(msg);print("p2 === msg is", p2 === msg);print("p2.valueOf() is", p2.valueOf());print("typeof p2 is", typeof p2);print("p2.valueOf() === msg is", p2.valueOf() === msg);
p1.valueOf() is Hellotypeof p1 is objectp1.valueOf() === str is truep2 === msg is truep2.valueOf() is Hellotypeof p2 is objectp2.valueOf() === msg is false
Table 4-11 contains the list ...
Read now
Unlock full access