js check if variable is string
if (typeof myVar === 'string'){
//I am indeed a string
}if (typeof myVar === 'integer'){
//I am indeed an integer
}
if (typeof myVar === 'boolean'){
//I am indeed a boolean
}var booleanValue = true;
var numericalValue = 354;
var stringValue = "This is a String";
var stringObject = new String( "This is a String Object" );
alert(typeof booleanValue) // displays "boolean"
alert(typeof numericalValue) // displays "number"
alert(typeof stringValue) // displays "string"
alert(typeof stringObject) // displays "object"
let eventValue = event.target.value;
if (/^\d+$/.test(eventValue)) {
eventValue = parseInt(eventValue, 10);
}
//If value is a string, it converts to integer.
//Otherwise it remains integer.
Also in JavaScript:
- node.js express
- install node modules
- how to change the font family using jquery
- get current directory vbscript
- react native flexbox 2 columns 1 fixed width
- how can prevent morgan to work in test enviroment
- oncheck checkbox javascript
- add property to object javascript
- how to check if 2 images are touching js
- jquery redirect to url
- react create array
- js unique using set
- go to next route vuejs
- angular add bootstrap
- How to Submit Forms and Save Data with React.js
- javascript function return boolean
- javascript get multiple elements by id
- how to push mutual array elements in an array nested loop javascript
- button click function in js
- discord js fetch user
- displaying the date react
- momentjs docs
- double question mark javascript
- for of mdn