How can I check if a var is a string in JavaScript?

I’ve tried this and it doesn’t work…

var a_string = "Hello, I'm a string.";

if (a_string typeof 'string') {
    // this is a string
}

7 Answers
7

Leave a Reply

Your email address will not be published. Required fields are marked *