variable javascript definition code example

Example 1: js variable

var Number = 5;
var String = "Hi!";
var boolen1 = true;
var boolen2 = false;
var array = [11, "Hi!", true];
var object = {age:11, speach:"Hi!", likes_Bananas:true};

Example 2: javascript variable

var user_name = prompt("Please enter your name:", "Type here");
alert("Hello " + user_name);

Example 3: js var

var a;
console.log(a);                // scrive in console "undefined" o "" a seconda del browser usato.
console.log('still going...'); // scrive in console "still going...".

Example 4: Create variable javascript

//Assigns the value bar to the variable foo
var foo = bar;

Example 5: javascript define variable

var variable1 = "some variable content";