Home > Web Front-end > JS Tutorial > Javascript string extension library code_javascript skills

Javascript string extension library code_javascript skills

WBOY
Release: 2016-05-16 18:30:12
Original
878 people have browsed it

Javascript's native String processing functions are not rich enough.
Native string function: http://www.jb51.net/w3school/js/jsref_obj_string.htm

Question 1: Is there an extension library just for String type?
Yes, not many, not comprehensive.

View 2: The power of JQuery lies in DOM operations, so we don’t want the js string extension library to be developed based on jquery. Do you agree?

Question 3: What kind of string extension function do we need?
For this question, you can refer to other js libraries and string operation functions in other languages ​​

Prototype.js extension to the String type:
http://api.prototypejs. org/language/string/

String type function reference in other languages
C#:http://msdn.microsoft.com /zh-cn/library/system.string_members(v=VS.80).aspx
Java:http://java.sun. com/j2se/1.4.2/docs/api/java/lang/String.html
Python:http://docs.python. org/library/stdtypes.html#string-methods
Perl:, perl is a process-oriented programming language, there is no concept of string objects, all string-related operations Functions are all scattered, haha.

Question 4: What is the best programming style for String function extension?
String.prototype.trim = function()
{
// Use regular expressions to replace leading and trailing spaces with empty strings.
return this.replace(/(^s*)|(s*$)/g, "");
}

Question 5: More abstractly, can all operating functions be considered Are they all for adding, deleting, modifying, checking, and type conversion of strings?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template