How can I determine whether a variable is a string or something else in JavaScript?
This is what works for me:
if (typeof myVar === 'string' || myVar instanceof String) // it's a string else // it's something else
2.1m questions
2.1m answers
60 comments
57.0k users