Repository navigation
Expand file tree
/
Copy path2-01.String.html
More file actions
104 lines (79 loc) · 2.12 KB
/
Copy path2-01.String.html
File metadata and controls
104 lines (79 loc) · 2.12 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html>
<head>
<title>Document</title>
</head>
<body>
<script>
var txt = "ABCDEFGHIJKLMN";
console.log(txt.length); //글자길이
//indexOf
var str = "Please locate where 'locate'";
console.log(str.indexOf("John"));
if(str.indexOf("John") > -1) {
console.log("locate문자 발견");
}
//lastIndexOf
console.log(str.lastIndexOf("locate"));
console.log(str.search("locate"));
//slice
var str = "Apple, Banana, Kiwi";
// console.log(str.slice(7,13));
// console.log(str.slice(7));
// console.log(str.slice(-12,-6));
//substring
console.log(str.substring(7,13));
//substr
console.log(str.substr(7,6));
var birthday = "970527";
console.log(birthday.substr(0,2));
console.log(birthday.substr(2,2));
var birthday = "1997-05-27";
console.log(birthday.substring(0,birthday.indexOf("-")));
//repace
// var str = "Please visit here!";
// var str2 = str.replace("here","there");
// console.log(str2);
// var str = "Please visit here here here!";
// var str2 = str.replace("here","there");
// console.log(str2);
var str = "Please visit here HERE here!";
var str2 = str.replace(/here/gi,"there");
console.log(str2);
//uppercase
console.log(str.toUpperCase());
//lowercase
console.log(str.toLowerCase());
//john
//JOHN
//
//데이터베이스 john, John
//concat
var txt1 = "Hello";
var txt2 = "World";
var txt3 = txt1 + " " + txt2;
console.log(txt3);
var txt4 = txt1.concat(" ",txt2);
console.log(txt4);
//trim
var str = " Hello World! ";
console.log(str);
console.log(str.trim());
//padStart
var str = "15";
console.log(str.padStart(2,0));
//padEnd
console.log(str.padEnd(4,0));
//charAt
var str = "Hello world";
console.log(str.charAt(1));
//split
var tags = "키보드,기계식,블루투스";
var arr = tags.split(",");
console.log(arr);
var birthday = "1997-06-12";
var arr2 = birthday.split("-");
console.log(arr2);
</script>
</body>
</html>