-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08_Strings.js
41 lines (25 loc) · 1.03 KB
/
08_Strings.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
let fName = "Sachin";
let lName = "Kumar";
console.log(fName + " " + lName); //this is old and inefficient method for concat
// ------------------------------------------------------------------------------
//Best Method for conacatenation use backticks `` or we called placeholders as well.
console.log(`My first name is ${fName} and the last is ${lName}.`);
//Strings are Primitve data type but if we make it as:
const myName = new String("Sachin Kumar");
// console.log(myName[0]);
// console.log(myName.__proto__);
// console.log(myName.length);
// console.log(myName.toUpperCase());
console.log(myName.charAt(2));
console.log(myName.indexOf('t'));
const newString = myName.substring(0, 4)
console.log(newString);
const anotherString = myName.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('sundar'))
console.log(myName.split('-'));