DEV Community

Discussion on: JavaScript Array methods

Collapse
 
mellen profile image
Matt Ellen • Edited

It might be worth mentioning that sort without a comparison function sorts by converting the elements to strings and using string comparison, so [3,7,2,1,35,24].sort() will end up as [1,2,24,3,35,7].

Collapse
 
frikishaan profile image
Ishaan Sheikh

Thanks for pointing out.