Basic OF JavaScript
One think before we learn of JavaScript we must know about our weapons, yes weapons because it is like we were at war :D
We need :
- Web Browser, like Google Chrome, Mozilla Firefox, Safari, Opera and anymore
- Or you can use with online editor, i recommend jsfiddle
Part 1 Variable
Variables are used to store data.
Here is the syntax for declaring a variable:
var nameVariable = "nameVariable";Part 2 Data Type
JavaScript have many data type, such as:
- String
- Number
- Boolean
- Array
- Object
- Function
- Undefined
- Null
String
String is the data type used to represent words or sentences.
Get Zainal Mustofa’s stories in your inbox
Join Medium for free to get updates from this writer.
E.g
var name = "Zainal Mustofa";Number
Number is the type of data used to represent numbers, either integer, real, exponential and others.
E.g
var age = 22;
var weight = 50.12;Boolean
Boolean is the type of data used to say yes or no, true or false.
E.g
var started = TRUE;
var rollback = FALSE;Function
DRY ( Don’t Repeat Your self )Function is cut pieces of code instructions that can be invoked repeatedly.
E.g
var thisOdd = function(value){
return value % 2 == 0;
};Array
An array is a data type such as a container to hold one or more data. Arrays can accommodate all types of data contained in javascript.
E.g
var days = ["Moday","Tuesday","Sapturday","Moday"];
var value = [5,7,8,2.4,4.5,10];
var mix = [
"gfyty$^%",
12.3,
NULL,
TRUE,
FALSE,
["a","b","C"]
];Object
Object almost similar to Array. The difference is, each data element that is accommodated in it has a name or a “key”.
E.g
var person = {
name : "zainal",
age : 17,
"weight" : 60.4,
"status" : TRUE,
"child": NULL
};







