-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpolation.html
More file actions
40 lines (31 loc) · 1.03 KB
/
interpolation.html
File metadata and controls
40 lines (31 loc) · 1.03 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
<!--interpolation
String interpolation:
> string interpolation replaces the expressions in the string with actual
values of the specified variables.
> sub dynamically var/expr/fun-call in between string
> operator is ${}
> string should be enclosed with in backtick(``), but not "" and ''.
> it is the new feature if js which comes under ECMAScript.
Syn: ${var} ${expr} ${fun call}
`text${var}text${expr}text${fun call}....`
Use: while printing data & assigning values to variables
-->
<script>
let n="ram";
document.write(n+"<br>");
document.write(`${n}<br>`);
//document.write("${n}<br>"); invalid
document.write("sum is 10+20<br>");
document.write(`sum is ${10+20}<br>`);
document.write(`res is ${10>20}<br>`);
let tn=10;
for(let i=1;i<=10;i++)
document.write(`${tn}*${i}=${tn*i}<br>`);
let st=`Hi ${n}`;
document.write(`${st} <br>`);
let x=15,y=9, res;
res=`Sum is ${x+y}<br>Product is ${x*y}<br>
Mod is ${x%y}`;
//document.write(`${res} <br>`);
document.write(res);
</script>