[] is not identical to [] [duplicate]
问题 This question already has answers here : How to compare arrays in JavaScript? (55 answers) Closed 5 years ago . I was asked to write a function sortByFoo in Javascript that would react correctly to this test : // Does not crash on an empty array console.log(sortByFoo([]) === []); But I've tried something : [] === []; >> false Just so I can be sure, such a test would always fail, no matter the sortByFoo function, wouldn't it ? But I'd like to have an explanation on why this happens. Why [] isn