1if (typeof myVar === 'integer'){
2 //I am indeed an integer
3}
4
5if (typeof myVar === 'boolean'){
6 //I am indeed a boolean
7}
1var booleanValue = true;
2var numericalValue = 354;
3var stringValue = "This is a String";
4var stringObject = new String( "This is a String Object" );
5alert(typeof booleanValue) // displays "boolean"
6alert(typeof numericalValue) // displays "number"
7alert(typeof stringValue) // displays "string"
8alert(typeof stringObject) // displays "object"
9
1let eventValue = event.target.value;
2
3 if (/^\d+$/.test(eventValue)) {
4 eventValue = parseInt(eventValue, 10);
5 }
6
7//If value is a string, it converts to integer.
8
9//Otherwise it remains integer.