This is what works for me:
if (typeof myVar === 'string' || myVar instanceof String)
// it's a string
else
// it's something else
More Related Contents:
- Regular expression to get a string between two strings in Javascript
- How can I extract a number from a string in JavaScript?
- How to sort strings in JavaScript
- Regular Expression to get a string between parentheses in Javascript
- Insert a string at a specific index
- Optimum way to compare strings in JavaScript? [duplicate]
- How to create streams from string in Node.Js?
- What does ${} (dollar sign and curly braces) mean in a string in JavaScript?
- How to insert variables in JavaScript strings?
- JavaScript replace() method dollar signs
- How can I use jQuery to style /parts/ of all instances of a specific word?
- Is there a JavaScript strcmp()?
- How can I insert new line/carriage returns into an element.textContent?
- How to sort an array based on the length of each element?
- Reversing a string in JavaScript
- How to extract a string using JavaScript Regex?
- What’s the point of new String(“x”) in JavaScript?
- How to remove part of a string?
- Javascript unicode string, chinese character but no punctuation
- Format a JavaScript string using placeholders and an object of substitutions?
- How to convert a String to long in javascript?
- Remove occurrences of duplicate words in a string
- Convert string to datetime
- JavaScript adding a string to a number
- Extract the text out of HTML string using JavaScript
- How would you turn a JavaScript variable into a Template literal?
- What is the difference between ‘ and ” in JavaScript?
- How to add spaces between every character in a string?
- how to split a string in javascript [duplicate]
- javascript – Convert array to string while preserving brackets