Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use trim in javascript

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use trim in javascript, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The javascript trim method is used to remove the leading and trailing blank characters of a string, its syntax is "string.trim ()", and the return value is the string that removes the leading and trailing spaces.

This article operating environment: Windows7 system, javascript1.8.5 version, DELL G3 computer

What is the use of javascript trim?

JavaScript trim () method:

The trim () method is used to remove the leading and trailing white space characters of a string, which include: spaces, tabs tab, newline characters, and so on.

The trim () method does not change the original string.

The trim () method does not apply to null, undefined, Number types.

Grammar

String.trim ()

Return value

String, which returns the string that removes the leading and trailing spaces.

Example

If your browser does not support the trim () method, you can use regular expressions to do so:

Function myTrim (x) {return x.replace (/ ^\ s + |\ ssteps Universalgm law');} function myFunction () {var str = myTrim ("Runoob"); alert (str);}

Output result:

Runoob thank you for reading this article carefully. I hope the article "how to use trim in javascript" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report