JavaScript Quiz Question #1: Array Sort Comparison

nas5w

Nick Scialli (he/him)

Posted on April 21, 2020

JavaScript Quiz Question #1: Array Sort Comparison

Consider the following arrays. What gets logged in various sorting conditions?

const arr1 = ['a', 'b', 'c'];
const arr2 = ['b', 'c', 'a'];

console.log(
  arr1.sort() === arr1,
  arr2.sort() == arr2,
  arr1.sort() === arr2.sort()
);
Enter fullscreen mode Exit fullscreen mode

A) true true true
B) true true false
C) false false false
D) true false true

Put your answer in the comments!

💖 💪 🙅 🚩
nas5w
Nick Scialli (he/him)

Posted on April 21, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related