Skip to content

Commit 2625e40

Browse files
authored
Create 字符串原型去空格.html
1 parent 0800a83 commit 2625e40

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

字符串原型去空格.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
</head>
7+
<body>
8+
9+
</body>
10+
<script>
11+
var str = " hello world ";
12+
13+
String.prototype.trim = function()
14+
{
15+
var myreg =/(^\s+|\s+$)/g;
16+
return this.replace(myreg,"");
17+
18+
}
19+
console.log(str);
20+
21+
22+
console.log(str.trim());
23+
24+
</script>
25+
</html>

0 commit comments

Comments
 (0)