Table of Contents

ECMAScript support

EcmaScript 5.1

Full support.

ECMAScript 2016+

Regular expressions flags are only partially supported. The flags d', s', 'v', and 'y' are ignored.

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

Array.prototype.filterMap( proc, [ thisArg ] )

As Array.prototype.map but filters out elements for which proc returns false.

Examples:

[1, -1, 2, -3 ].filterMap( x => x > 0 ? x * 10 : false ) -> [ 10, 20 ]
[1, -1, 2, -3 ].map( x => x > 0 ? x * 10 : 0 ) -> [ 10, 0, 20, 0 ]