Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

if typeof variable javascript

// check if a variable is of a certain type
var myVar = "This is a string";

if (typeof myVar === "string") {
	console.log("It's a string!");
} else if (typeof myVar === "number") {
	console.log("It's a number!");
};
// would return "It's a string!" in this case
 
PREVIOUS NEXT
Tagged: #typeof #variable #javascript
ADD COMMENT
Topic
Name
3+4 =