Skip to content

suppress empty strings in the output array when the…

“suppress empty strings in the output array when the separator is a regular expression: var f = '|a|b|c|'.split(/\|/); // f is ['a', 'b', 'c'] on some systems, and // f is ['', 'a', 'b', 'c', ''] on others string.substring(start, end ) The substring method is the same as the slice method except…” quote by Douglas Crockford
Download Open image
““suppress empty strings in the output array when the separator is a regular expression: var f = '|a|b|c|'.split(/\|/); // f is ['a', 'b', 'c'] on some systems, and // f is ['', 'a', 'b', 'c', ''] on others string.substring(start, end ) The substring method is the same as the slice method except that it doesn’t handle the adjustment for negative parameters. There is no reason to use the substring method. Use slice instead. string.toLocaleLowerCase( ) The toLocaleLowerCase method produces a new string that is made by converting this string to lowercase using the rules for the locale. This is primarily for the benefit of Turkish because in that language 'I’ converts to 1””

Douglas Crockford

About This Quote

This interpretation was drafted with AI assistance. It is one reading of the quote, not the author's own explanation.

The quote discusses best practices for string handling in programming, emphasizing consistent splitting, preferring slice over substring, and locale-aware case conversion.

In simple terms: Use reliable string methods and locale-aware case conversion.

Key Takeaway

Prefer slice, handle empty splits, respect locale.

Themes

programming best practices string handling

Mood

technical informative

Type

advice instructional

When to use this quote

  • data parsing
  • internationalization
  • code portability

Key Concepts

splitting slice vs substring locale case conversion

Questions to Reflect On

  • How do you ensure consistent split results?
  • When should you choose slice over substring?
A Different Perspective

Neglecting locale can cause bugs in Turkish text.

★ ★ ★ ★ ★ No ratings yet

More by Douglas Crockford

Explore all 33 Douglas Crockford quotes

More Productivity quotes

Browse all 3,424 Productivity quotes