📌  相关文章
📜  在线 javascript 编码测试 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:23.903000             🧑  作者: Mango

代码示例2
function checkArrayEqualElements(_array)
{
   if(typeof _array !== 'undefined')    
  {
   return !!_array.reduce(function(a, b){ return (a === b) ? a : NaN; });
  }
  return "Array is Undefined";
}
//usage
let myArray1 = ["Javascript", "Javascript", "Javascript", "Javascript"];
let myArray2 = ["Javascript",1,"Javascript"];
let myArray3 ;
console.log(checkArrayEqualElements(myArray1));
console.log(checkArrayEqualElements(myArray2));
console.log(checkArrayEqualElements(myArray3));