Does console.log invokes toString method of an object?
问题 As per this documentation, The string representations of each of these objects are appended together in the order listed and output. Also as per answer The + x coerces the object x into a string, which is just [object Object]: So, my question is If I do str = new String(\"hello\") console.log(str) //prints the string object but not \'hello\' console.log(\"\"+str) //prints \"hello\" So, in first case, it simply prints the object (doesn\'t invoke the toString() method). But in second case, it