[{}] is it array or object code example

Example 1: javascript check if is array

var colors=["red","green","blue"];

if(Array.isArray(colors)){
    //colors is an array
}

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