Compare String in Javascript

item1.attr.localeCompare(item2.attr);