Advertisement
deddyprianto

Check If A Variable Is An Array

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