Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 7. Check If A Variable Is An Array
- You can check if any Variable is an Array or not using the Array.isArray() method.
- let fruit = 'apple';
- let fruits = ["apple", "banana", "mango", "orange", "grapes"];
- const isArray = (arr) => Array.isArray(arr);
- console.log(isArray.(fruit)); //output - false
- console.log(isArray.(fruits)), //output- true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement