From 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:43:23 -0500 Subject: initial commit --- .../global_objects/string/padstart/index.html | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html (limited to 'files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html') diff --git a/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html b/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html new file mode 100644 index 0000000000..8a08d5924f --- /dev/null +++ b/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html @@ -0,0 +1,96 @@ +--- +title: String.prototype.padStart() +slug: Web/JavaScript/Reference/Global_Objects/String/padStart +translation_of: Web/JavaScript/Reference/Global_Objects/String/padStart +--- +
{{JSRef}}{{SeeCompatTable}}
+ +

padStart() 會將用給定用於填充的字串,以重複的方式,插入到目標字串的起頭(左側),直到目標字串到達指定長度。

+ +

Syntax

+ +
str.padStart(targetLength [, padString])
+ +

Parameters

+ +
+
targetLength
+
目標字串被填充後的長度。如果此參數小於原字串的長度,那將直接返回原字串。
+
padString {{optional_inline}}
+
用來填充的字串。如果填充字串太長,則由左側開始,擷取所需要的長度。此參數預設值是空白 " " (U+0020).
+
+ +

Return value

+ +

目標字串被填充到指定長度後,所得的新字串。

+ +

Examples

+ +
'abc'.padStart(10);         // "       abc"
+'abc'.padStart(10, "foo");  // "foofoofabc"
+'abc'.padStart(6,"123465"); // "123abc"
+
+ +

Specifications

+ +

這個方法還沒有被納入 ECMAScript 標準。現在還只是個提案

+ +

Browser compatibility

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(57)}} 15{{CompatGeckoDesktop(51)}}{{CompatNo}}{{CompatOpera(44)}}{{CompatSafari(10)}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatUnknown}}{{CompatChrome(57)}}{{CompatGeckoMobile(51)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatSafari(10)}}
+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf