how to check if array or object in js code example
Example 1: if object is array javascript
Array.isArray(object);
Example 2: javascript is array or object
const data = [1,2,3,4,5];const isArray = Object.prototype.toString.call(data) === '[object Array]';console.log(isArray); // trueconst data = {id: 1, name: “Josh”};const isArray = Object.prototype.toString.call(data) === '[object Array]';console.log(isArray); // false