Sitemap

Basic OF JavaScript

2 min readNov 3, 2015

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 :

  1. Web Browser, like Google Chrome, Mozilla Firefox, Safari, Opera and anymore
  2. 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:

  1. String
  2. Number
  3. Boolean
  4. Array
  5. Object
  6. Function
  7. Undefined
  8. 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
};

--

--

Zainal Mustofa
Zainal Mustofa

Written by Zainal Mustofa

Full Stack Ruby On Rails Developer