The typeof operator returns a string. String are compared by its numeric value.
So, the < comparison order would be:
type charCode ("tfnosux".charCodeAt(i)) Example
boolean 98 true
function 102 Date
number 110 123
object 111 []
string 115 ""
undefined 117 undefined
xml 120 <x></x>
tfnosux are the first characters of the types. The charCodeAt method returns the numeric charCode of a character in JavaScript.
I have added an example of each type at the previous block. Most JavaScript developers know about the first types. The final type, xml, is less commonly known, and can be obtained by using typeof on EX4.
Demo of typeof: http://jsfiddle.net/9G9zt/1/
typeof()returns a string, so its really a lexographic comparison.Array.prototype.sort. Here's an example