truncate :: String

each(iterator) -> Hash Iterates over the name/value pairs in the hash.

Of course, truncate() does not modify strings which are shorter than the specified length.

If unspecified, the length parameter defaults to 30 and the suffix to "...".

Note that truncate() takes into consideration the length of the appended suffix so as to make the returned string of exactly the specified length.

Examples

'A random sentence whose length exceeds 30 characters.'.truncate();

// -> 'A random sentence whose len...'

'Some random text'.truncate();

// -> 'Some random text.'

'Some random text'.truncate(10);

// -> 'Some ra...'

'Some random text'.truncate(10, ' [...]');

// -> 'Some [...]'

Prototype API 1.5.0 - prototypejs.org