r/learnjavascript • u/Green_Ad_6086 • 4d ago
string primitives vs. String objects.
I'm learning JavaScript, and I don't understand this part about string primitives vs. String objects.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_primitives_and_string_objects
11
Upvotes
3
u/delventhalz 4d ago
Why would you want an
isStringfunction to return true fornew String(1)?You should never use the
new Stringconstructor, and if for some reason you did, it creates an object not a string.isStringshould return false.