-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring.js
50 lines (36 loc) · 1.44 KB
/
string.js
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
const name = "hitesh"
const repoCount = 50
//console.log(name+repoCount + "Value");
console.log(`Hello my name is ${name} and my repo count is ${repoCount}`);
const gameName = new String('hitesh-hc');
console.log(gameName[0]);
console.log(gameName.__proto__);
console.log(gameName.length);
console.log(gameName.toUpperCase());
console.log(gameName.charAt(2));
console.log(gameName.indexOf('t'));
const newString=gameName.substring(0, 4);
console.log(newString);
const anotherString = gameName.slice(-8, 4);
console.log(anotherString);
const newStringOne = " hitesh "
console.log(newStringOne);
console.log(newStringOne.trim());
const url = "https://hitesh.com/hitesh%20choudhary"
console.log(url.replace('%20','-'));
console.log(url.includes('hitesh'));
console.log(gameName.split('-'));
console.log(String.fromCharCode(65)); // Output: "A"
console.log(String.fromCharCode(72, 101, 108, 108, 111)); // Output: "Hello"
console.log(String.fromCodePoint(128512)); // Output: "😀" (smiley emoji)
console.log(String.fromCodePoint(9731)); // Output: "☃" (snowman symbol)
const myname = "Alice";
console.log(String.raw`Hello, ${myname}\nHow are you?`);
// Output: "Hello, Alice\nHow are you?" (keeps \n raw)
let text = "Click here";
let result = text.anchor("myAnchor");
console.log(result);
//<a name="myAnchor">Click here</a>
//str.at(index)
let str = "Hello, world!";
console.log(str.at(7)); // "w"