What's the point of new String(“x”) in JavaScript?
问题 What are the use cases for doing new String("already a string") ? What's the whole point of it? 回答1: There's very little practical use for String objects as created by new String("foo") . The only advantage a String object has over a primitive string value is that as an object it can store properties: var str = "foo"; str.prop = "bar"; alert(str.prop); // undefined var str = new String("foo"); str.prop = "bar"; alert(str.prop); // "bar" If you're unsure of what values can be passed to your