A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.w3schools.com/jsref/jsref_string_padstart.asp below:

Website Navigation


JavaScript String padStart() Method

JavaScript String padStart() Examples

Pad a string with "0" until it reaches the length 4:

let text = "5";
let padded = text.padStart(4,"0");

Try it Yourself »

Pad a string with "x" until it reaches the length 4:

let text = "5";
let padded = text.padStart(4,"x");

Try it Yourself » Description

The padStart() method pads a string from the start.

The padStart() method pads a string with another string (multiple times) until it reaches a given length.

Example

let numb = 5;
let text = numb.toString();
let padded = text.padStart(4,"0");

Try it Yourself » Syntax

string.padStart(length, string)

Parameters Parameter Description length Required.
The length of the resulting string. string Optional.
The string to pad with.
Default is space. Return Value Type Description A string A String of the specified length, with the padding applied from the start. Browser Support

padStart() is a JaveScript 2017 feature.

ES 2017 is supported in all modern browsers since September 2017:

Chrome 58 Edge 15 Firefox 52 Safari 11 Opera 45 Apr 2017 Apr 2017 Mar 2017 Sep 2017 May 2017

Track your progress - it's free!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4