🌐 Frontend & Web

JavaScripts substring(): Eigenwillig, nützlich, total verwirrend

JavaScripts substring() wirkt harmlos. Sie tauscht Argumente und vergibt NaN – hasst selbst alte Hasen.

Diagramm zu JavaScript-String-Indizes und substring()-Auszügen

⚡ Key Takeaways

  • substring() tauscht Argumente automatisch und vergibt NaN/Negative – praktisch, aber bugsichtbar machend.
  • Slice() für Negativzahlen und Vorhersagbarkeit wählen; substring nur für Legacy-Toleranz.
  • Immer Indizes prüfen; JS-Strings zerlegen UTF-8-Emojis ohne Vorsicht.
Published by

DevTools Feed

Ship faster. Build smarter.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.