-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplateString.js
62 lines (32 loc) · 971 Bytes
/
templateString.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
51
52
53
54
55
56
57
58
59
60
61
62
var a = `Thrishul ${returnTrue()?'Sherigar':(returnFalse()?'Thrishul':'Devadiga')}`;
// console.log(a);
function returnTrue(){
return true;
}
function returnFalse() {
return false;
}
//tagged Templates
//Java script provides with a way to atg a string with function this is called tagged templates
function highlight(strings, name, place) {
for(var i = 0; i < strings.length; i++) {
// console.log(strings[i]);
}
// console.log(name);
// console.log(place);
return 'Mangalore';
}
var name = 'Thrishul';
var place = 'Sherigar';
var a = highlight `my name is ${name} and iam from ${place}`;
// console.log(a);
//Raw strings
//Raw string helps you to process the passed as it is without processing escape sequences
function highlight1(string) {
// console.log(string);
console.log(string.raw[0]);
}
//Creating raw Strings
var m = String.raw `My name is thrishul Sherigar and \n\n`;
console.log(m);
//