Primitive Data types

Primitive data types hold only one value

Simple structures

"immutable" <- internally

 

Non-Primitive Data types

Non-primitive data types hold multiple values

Complex structures

 mutable

 

 

Declaring and assigning a variable

<head>

<script>

//Number
var score = 0;

//String
var playerName = "Jesse Freeman";


//Boolean
var isAlive = true;

</script>

</head>


 

Numbers

Numbers can contain .... er.... numbers. For example 1,2,3,4.5,4.6

Strings

Strings can contain words such as "Your crew is featherweight, my code will make you levitate"

var myRap = "You know it’s funny when it rains it pours<br/>
They got money for wars, but can’t feed the poor"

 

You can combine two strings together with...

var firstName = "Mos";
var secondName = "Def";

var myCrazyNewString = firstName + " " + secondName;

alert(  myCrazyNewString  );

 

Booleans

Booleans can store only two values. true or false

var winnersWorkHarder = true;

var successIsEasy = false;


alert( "Did you know winners work hard: " + winnersWorkHarder );