-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsVarriables.js
More file actions
71 lines (58 loc) · 1.56 KB
/
Copy pathJsVarriables.js
File metadata and controls
71 lines (58 loc) · 1.56 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function Varriable1(){
x=10;
y=20;
z=x+y;
document.write("The sum of x and y is :"+z);
}
function Varriable2(){
var a=10; //varriable declared as var may be redeclare
var b=20;
var c="the sum is:"
sum1=c+a+b;
document.write(sum1);
}
function Varriable3(){
$="my name is :";
fname="harendra ";
lname="prajapati";
all1=$+fname+lname;
document.write(all1);
}
function Varriable4(){
var num=10;
{
var num=20;
}
document.write(num); /* have not a block scope here outpot will be 20 but whenwe use let keyword to assign
a varriable it removes this problem.*/
}
function Varriable5(){
let num=10;
{
let num=20;
}
document.write(num); /*here outpot will be 10 have a block scope*/
}
function Varriable6(){
const a=100; //can not be redeclare ,reassigned,have a block scope
document.write("The value of a is"+a);
}
function const1(){
// You can create a constant array:
const cars = ["Saab", "Volvo", "BMW"];
document.write("cars are before adding :"+cars);
// You can change an element:
cars[0] = "Toyota";
// You can add an element:
cars.push("Audi");
document.write("cars are after adding :"+cars);
}
function const2(){
// You can create a const object:
const car = {type:"Fiat", model:"500", color:"white"};
// You can change a property:
car.color = "red";
// You can add a property:
car.owner = "Johnson";
document.write(",this added"+car);
}