I have an argument to a method that I need to make sure is a string. Using var instanceof String
was failing, so I did a console.log(var.constructor.name, var instanceof String
and got this output:
String false
Why does JavaScript consider the constructor's name to be 'String'
but doesn't consider the variable to be an instance of String
?