檢查數組的所有值是否相等 - Check if all values of array are equal

問題:

I need to find arrays where all values are equal.我需要找到所有值都相等的數組。 What's the fastest way to do this?這樣做的最快方法是什麼? Should I loop through it and just compare values?我應該遍歷它並只比較值嗎?

['a', 'a', 'a', 'a'] // true
['a', 'a', 'b', 'a'] // false

解決方案:

參考一: https://stackoom.com/question/10EdX
參考二: Check if all values of array are equal
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章