-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjs14.html
More file actions
45 lines (37 loc) · 1.51 KB
/
js14.html
File metadata and controls
45 lines (37 loc) · 1.51 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
<!--demo on js -->
<h3>demo on operators</h3>
<script>
let x=15,y=7;
//arithmatic operators +, -, *, /, %, **
document.write(x+y, '<br>');
document.write(y*3, '<br>');
document.write(y**3, '<br>');
document.write(x/4, '<br>');
//relational operators >, <, >=, <=, ==, !=, ===(strict equal), !==(strict not equal)
document.write(x>=0, '<br>');
let z="7";
document.write(y==z, '<br>');//check only value(data) so ans is true
document.write(y===z, '<br>');//check value(data) with data type so ans is false
//logical operators &&, ||, ! (for comparing multiple conditions)
document.write(x>=0 && x<=10, '<br>');
document.write(!(y<0) , '<br>');
/*Assignment operators = (to store the data into memory block)
shorthand ope +=, -=,*=, /=, %=, **=
*/
x+=30; //x=x+30;
document.write(x, '<br>');
//concatination ope + (any side(left or right) if string is available then concat perform
document.write("rama"+ " rao", '<br>');
document.write(100+"mangos<br>");
document.write(22+true+"<br>");
//unary oper ++(increment)-> to add one number to existent number
// --(decrement)-> to substract one number to existent number
/* ++ ++var var++
-- --var var--
(pre) (post) */
x++;
document.write(x,"<br>");
//conditional ope (ternary oper) ->to perform decision making (?:)
// cond ? stat1 : stat2
document.write(y%2===0?"even" : "odd");
</script>