The extended implementation code of some Array and String prototype objects collected. For details about js learning, refer. It can also customize the expansion of string and array data. From the worry-free script collection, some are indeed good,
Example of String. prototype usage in JavaScript, javascriptprototype
This example describes the usage of String. prototype in JavaScript. Share it with you for your reference. The details are as follows:
// Returns the length of the character. A
This article mainly introduces the usage of String. prototype in JavaScript. The example analyzes the functions and usage skills of prototype. if you need it, refer to the example below to describe the usage of String. prototype in JavaScript. Share
From the worry-free script collection, some are indeed good, more practical, it is worth collecting.
How to extend the prototype object of Array
Copy codeThe Code is as follows: // Delete the data in the array
Array. prototype. del = function (n)
{
From the worry-free script collection, some are indeed good, more practical, it is worth collecting.How to extend the prototype object of ArrayCopy codeThe Code is as follows:// Delete the data in the arrayArray. prototype. del = function (n){If (n
In the morning, I saw the article "javascript Weekly Guide" [Phase 3], which contains an articleArticle(Extending JavaScript-the right way), I think it is not bad. I will share the translation with you. This article is not translated word by word
In The morning, I saw The article "JavaScript Weekly Guide" [Phase 3], in which I found an article (Extending JavaScript-The Right Way). I think it is not bad. I will share it with you through translation, this document is not translated word by
JavaScript already has many powerful built-in methods, but sometimes you don't need a function in the built-in method, how can we elegantly expand The JavaScript function? In The morning, I saw The article Extending JavaScript-The Right Way, the
In The morning, I saw The article "JavaScript Weekly Guide" [Phase 3], in which I found an article (Extending JavaScript-The Right Way). I think it is not bad. I will share it with you through translation, this document is not translated word by
// Function Name: trim// Function Description: removes spaces at the beginning and end of a string.// Creation Date:// Last Modify By: N/// Last Modify Date: N/String. prototype. trim = function (){Return this. replace (/(^ \ s *) | (\ s * $)/g ,"");
String extension method set, which can be javascript's string function more // get character array
String. prototype. ToCharArray = function ()
{
Return this. split ("");
}
// Obtain N identical strings
String. prototype. Repeat = function
A set of methods for removing spaces in JavaScript. The script home has previously released a lot of code for removing spaces, which is more comprehensive. Implementation 1
The Code is as follows:
String. prototype. trim = function (){Return this.
1.
VaR Reg =/^ (\ w | [\ u4e00-\ u9fa5]) * $ /;If (ARR = username. Match (REG )){Ti = 1;Return ture;}Else{Alert ("the user name can only contain English letters, numbers and Chinese characters. \ n check whether there are spaces or other symbols
Deleting spaces using the regular expression s + in js almost solves this problem. I would like to share with you the examples used in this project. I hope this will be helpful to you.
The following two requirements are required in the reply box
The W3C team's head was kicked off until javascript1.8.1 supported the trim function (with trimleft and trimright). Unfortunately, only firefox3.5 supported it now. Since the blank spaces on both sides of the string are too common, all major types
JS string Function Extension code. You can refer to the prototype usage method to expand your own string processing functions.
The Code is as follows:
/*************************************** ************** CreateBy: joe zhou* CreateDate: 2011-9-4
We recommend that you search for and collect many common js judgment functions. We recommend that you search for common js judgment functions.
*Determines whether the specified content is null. If it is null, a warning box is displayed.*/Function
The String extension method has been very busy and has no time to write your own things. But it is not a taste to watch the day without updating your mood. You only have to collect some good stuff from the Internet.
/*** Delete spaces at the
I have been very busy and have no time to write my own things, but it is not a taste to watch the day without updating my mood. I only have to collect some of the better stuff from the Internet.
/*** Delete spaces at the beginning and end
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.