Answers for "how to check if value is array in js"

9

check if a variable is array in javascript

// inside if else check
if(Array.isArray(myVarToTest)) {
	// myVatToTest is an array
} else {
	// myVarToTest is not an array
}
Posted by: Guest on January-08-2021
1

array value check javascript

const names = ["code","codepadding"]
const key = "codepadding";
var have = names.includes(key) // return true / false
if(have){
	//	do something
}
Posted by: Guest on February-24-2022
0

how to check value is array or not in javascript

// how to check value is array or not in javascript
const str = "foo";
const check = Array.isArray(str);
console.log(check);
// Result: false

const arr = [1,2,3,4];
const output = Array.isArray(arr);
console.log(output);
// Result: true
Posted by: Guest on January-07-2022

Code answers related to "how to check if value is array in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language