javascript variable

PHOTO EMBED

Fri Aug 26 2022 15:04:39 GMT+0000 (Coordinated Universal Time)

Saved by @callena #javascript

var myName;
// var keyword create a variable called myName

 //you can store a value in a variable with the assignment operator (=).
var a;
a = 7;
// this code assign the value 7 to variable a.

//you can assign the value of that variable to another variable using the assignment operator.
var myVar;
myVar = 5;
var myNum;
myNum = myVar;
// now the code assign the contents of a to variable b.

//It is common to initialize a variable to an initial value in the same line as it is declared.
var myVar = 0;

//But you can also declare a string variable like this:
var myName = "your name";
//"your name" is called a string literal, another example 
var myFirstName = "alya"
var myLastName = "shofiyah"

                                                                   
content_copyCOPY