-
Notifications
You must be signed in to change notification settings - Fork 0
/
11-2.html
84 lines (80 loc) · 2.92 KB
/
11-2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="./public/favicon.ico" />
<meta http-equiv="cache-control" content="no-cache" />
<title></title>
<link rel="stylesheet" href=" https://necolas.github.io/normalize.css/8.0.1/normalize.css" />
<link rel="stylesheet" href="./hightlight/default.min.css" />
<link rel="stylesheet" href="./css/main.css" />
<link rel="stylesheet" href="./css/copybutton.css" />
<link rel="stylesheet" href="./css/hightlight.css" />
<script src="./hightlight/hightlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.11/clipboard.min.js"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BEVZJDBC7Z"></script>
<script src="./js/gtag.js"></script>
</head>
<body>
<header>
<nav>
<h1>
<span id="toggle-menu"></span>
<a href="index.html"></a>
</h1>
</nav>
</header>
<main>
<aside>
<nav></nav>
</aside>
<article>
<h2 id="11-2">11-2 String.padEnd()</h2>
<p>
padEnd()
會將用給定用於填充的字串,以重複的方式,插入到目標字串的尾端(右側),直到目標字串到達指定長度。
</p>
<h3>Syntax</h3>
<p>str.padEnd(targetLength [, padString])</p>
<h3>Parameters</h3>
<h5>targetLength</h5>
<p>目標字串被填充後的長度。如果此參數小於原字串的長度,那將直接回傳原字串。</p>
<h5>padString (選擇性)</h5>
<p>
用來填充的字串。如果填充字串太長,則由左側開始,擷取所需要的長度。此參數預設值是空白 ' '
</p>
<pre><code class="language-js">
const str1 = 'Breaded Mushrooms';
console.log(str1.padEnd(25, '.'));
// Expected output: 'Breaded Mushrooms........'
const str2 = '200';
console.log(str2.padEnd(5));
// Expected output: '200 '
</code></pre>
<pre><code class="language-js">
'abc'.padEnd(10); // 'abc '
'abc'.padEnd(10, 'foo'); // 'abcfoofoof'
'abc'.padEnd(6, '123456'); // 'abc123'
'abc'.padEnd(1); // 'abc'
</code></pre>
<p>資料來源:</p>
<p>
<a
href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padEnd"
>
https://developer.mozilla.org/en-US/docs/Web/JavaScript/...
</a>
</p>
<p>
<a href="https://www.tabnine.com/code/javascript/functions/builtins/String/padEnd">
https://www.tabnine.com/code/javascript/....
</a>
</p>
</article>
</main>
</body>
<script type="module" src="./js/main.js"></script>
</html>