Table of Contents

ECMAScript support

EcmaScript 5.1

Full support.

ECMAScript 2016+

Extensions

Hop extends some standard JavaScript classes.

String.prototype.naturalCompare( string1, string1 )

This function compares string1 and string2 according to a natural string order. It returns a negative integer if string1 < string2. It returns zero if the string1 equal string2. It returns a positive integer if string1 > string2.

Examples:

"foo".naturalCompare( "foo" ) -> 0
"foo0".naturalCompare( "foo1" ) -> -1
"foo1".naturalCompare( "foo" ) -> 1
"rfc822.txt".naturalCompare( "rfc1.txt" ) -> -1
"1.002".naturalCompare( "1.010" ) -> -1