So far, we've used the isNaN function to check whether the variable is a string or an object, but it doesn't seem to work properly I wonder if I did it the right way.
if(isNaN(element))
element = document.querySelector(element);
I think there's something wrong, but I don't know what's right.
javascript string object
Try using the type of operator.
var booleanValue = true;
var numericalValue = 354;
var stringValue = "This is a String";
alert(typeof booleanValue) // "boolean"
alert(typeof numericalValue) // "number"
alert(typeof stringValue) // "string"
© 2024 OneMinuteCode. All rights reserved.