trim() in Javascript 🔥 #javascript #DSA #javascriptinterview

preview_player
Показать описание
In JavaScript, the trim() method is used to remove whitespace (spaces, tabs, or newlines) from both ends of a string. Here's how you can use it:

let str = " Hello, World! ";

It doesn't modify the original string; instead, it returns a new string with the whitespace removed.

This method is commonly used to clean up user input or to remove unnecessary whitespace from strings obtained from external sources before further processing.
Рекомендации по теме
Комментарии
Автор

Toh kya ye string k baad waale space bhi femove krta ya sirf starting waale?

marsimperfect
Автор

how we can remove the spaces between a string?

CodingWithAliyan
visit shbcf.ru