How to “instanceof” a primitive string (string literal) in JavaScript [duplicate]
问题 This question already has answers here : Why does instanceof return false for some literals? (10 answers) Closed 6 years ago . In JavaScript, I can declare a string in the following ways; var a = "Hello World"; var b = new String("Hello World"); but a is not an instance of String... console.log(a instanceof String); //false; console.log(b instanceof String); //true; So how do you find the type or " instanceof " a string literal? Can JavaScript be forced to create a new String() for every