-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut50.html
More file actions
54 lines (41 loc) · 1.33 KB
/
Copy pathtut50.html
File metadata and controls
54 lines (41 loc) · 1.33 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Javascript string functions</title>
<style>
</style>
</head>
<body>
<script>
var str = "This is a string"
console.log(str)
// first occournce of sub string
var position = str.indexOf('is');
console.log(position)
// last occournce of sub string
var position = str.lastIndexOf('is');
console.log(position)
// substring from a string
// var substr = str.slice(1,6)
// var substr = str.substring(1,6)
var substr1 = str.substr(1,3)
console.log(substr1);
// var replaced = str.replace('string', 'anand')
// 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 contain white spaces"
// console.log(strWithWhitespaces)
// console.log(strWithWhitespaces.trim())
// var char2 = str.charAt(2);
// var char2 = str.charCodeAt(2);
// console.log(char2);
console.log(str[3])
</script>
</body>
</html>