Question:

Why doesn't the following code work?

function badSortArgs () {
  var result = arguments.sort(function (x, y) {
    return x - y;
  });
  return result;
}
badSortArgs(1, 44, 3);

Answer:

arguments is an array-like object, but it's not actually an array. The sort() method is not defined for the arguments object.


Keywords:

© 2017 QuizBucket.org