Test to show ignorePunctuation in action

if ignorePunctuation is true, all punctuation, such as spaces and hyphens are not taken into account when sorting or searching.

by David Storey

JavaScript

var ignore = [true, false],
    locale = "en",
    searcher = null;

console.clear();

for (var i = 0; i < ignore.length; i++ ) {
    searcher = new Intl.Collator(locale, { usage: "search", ignorePunctuation: ignore[i] });
    console.log(searcher.compare("Helena Bonham Carter", "Helena Bonham-Carter"));
}