Home > Web Front-end > JS Tutorial > body text

Recommended articles about taking fixed length

黄舟
Release: 2017-06-12 09:36:05
Original
1177 people have browsed it

This article mainly introduces JavaScript string numbers left padding, right padding, fixed length, truncation extension function code. Friends in need can refer to it. Sometimes our dates and other less than two digits are padded with a 0 etc., you can use this. Everyone should understand this very well, so I won’t talk nonsense. The code is as follows: String.prototype.padLeft = Number.prototype.padLeft = function(total, pad) { return (Array(total).join(pad || 0) + this).slice(-total); }Test code: //fill "X".padLeft(5, "Y"); //Return: YYYYX (50).padLeft(5)

1. Detailed explanation of JavaScript string numbers left padding, right padding, fixed length, truncation extension function code

Recommended articles about taking fixed length

Introduction: This article mainly introduces JavaScript string numbers left padding, right padding, fixed length, truncation Extended function code, friends who need it can refer to

##2. Small example of php string interception php function intercepts fixed length string

Introduction: PHP string interception small example PHP function intercepts fixed length string

3. JS version gets the real length of the string and takes the fixed length characters String function_javascript skills

Introduction: JS version to get the real length of a string and a fixed-length string function

4 . JS simple example of intercepting fixed-length Chinese and English characters_javascript skills

Introduction: The following is a simple function I wrote to intercept fixed-length characters The string is applicable to both Chinese and English. If there is anything wrong, please correct me

The above is the detailed content of Recommended articles about taking fixed length. For more information, please follow other related articles on the PHP Chinese website!

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