-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtut_50.html
39 lines (36 loc) · 1.18 KB
/
tut_50.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
<!DOCTYPE html>
<html lang="en">
<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">
<title>JavaScript Sting Function</title>
</head>
<body>
<script>
var str ="This is a string"
console.log(str);
var position =str.indexOf('is');
console.log(position);
position=str.lastIndexOf('is');
console.log(position);
// substring from a string
// var substr=str.slice(2,6);
var substr1 =str.substr(1,7);
console.log(substr1);
// var replaced =str.replace('string','Saksham');
// console.log(str);
// console.log(replaced);
// console.log(str.toUpperCase());
// console.log(str.toLowerCase());
// var newString =str.concat(' New String');
// console.log(newString);
// var strWithwhitespaces=" this contains whitespaces "
// console.log(strWithwhitespaces);
// console.log(strWithwhitespaces.trim());
// var char3 =str.charAt(2);
// console.log(char3);
console.log(str[3]);
</script>
</body>
</html>