Just wondering why i got an error with the following simple JavaScript function
function highest(){
return arguments.sort(function(a,b){
return b - a;
});
}
highest(1, 1, 2, 3);
Error messsage : TypeError: arguments.sort is not a function.
I am confused as arguments it is an array (i thought). Please help and explain why. Many thanks

argumentsis not an array, take a look at this demo. It's anArguments Object, which only acts like an array. Same goes to many array-like objects returned by native functions such as.getElementsByClassName, for example, which returns anHTMLCollectionobject.argumentsis not an array. It has a length and indexed properties, but if you checkarguments instanceof Array, you’ll notice that it’sfalse(and thatObject.prototype.toString.call(arguments) === '[object Arguments]'). As such, it doesn’t have methods fromArray.prototype, includingsort.