How primitive data types (strings, numbers etc.) have access to methods like .toString(). We can even access to their proto's by typing variable.proto but they are not object.
CodePudding user response:
JavaScript automatically converts primitives to String objects, so that it's possible to use String object methods for primitive strings.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String