A Brief overview on “Java Script”


Introduction to JavaScript

Java Script is a simple, powerful language (scripting/programming) language that allows to implementation of complex features on web pages. It is a multi-paradigm, dynamic language with types and operators, standard built-in objects, and methods. Its syntax is based on the Java and C languages. it help us to make our web pages functional. So we call Java Script the heart of the web.

JavaScript supports object-oriented programming with object prototypes, instead of classes. it also supports functional programming, functions may be stored in variables and passed around like any other object.

There are three main advantages of JavaScript:

  • JavaScript is fully integrated with both HTML and CSS.
  • Simple things are easy to implement using JavaScript.
  • This language is supported by all modern browsers and is included by default.

JavaScript is the only language that supports these three features all at once, which makes JS the most frequently used technology for browser interface development.

Evolution of JavaScript

JavaScript is first and foremost the programming language of the web. It was invented in 1995 by Brendan Eich as LiveScript, who at the time worked for Netscape, which created the first popular web browser (Firefox’s ancestor).

After 1997, the ECMA standard established. In 1999 ES3 came. Finally, in 2009 Douglas Crockford came up with the idea of OOP in JavaScript(ES5), what most of us use now. In 2015 ES6/ECMAScript2015 comes out with many syntactic sugar and its continued as ES7(2017) ES8(2018) ES10(2019) and now it plays with 1.52 billion sites, which is 95% of 100%.

According to the 2020 StackOverflow developer survey, JavaScript is the most commonly used programming language for the eighth year in a row. It is currently used by 94.5% of all websites and, despite originally being designed as a client-side language, JavaScript has now made its way to the server-side of websites as Node.js, mobile devices as of React Native, and Ionic.

Data types and their use in JavaScript

The types of values that can be represented and manipulated in a programming language are known as data types. a data type, in programming, is a classification that specifies which type of value a variable has and what type of mathematical, relational, or logical operations can be applied to it without causing an error.

  • String ( str) - Used for a combination of any characters that appear on a keyboard, such as letters, numbers, and symbols.
  • Character (char) - Used for single letters.
  • Integer (int) - Used for whole numbers.
  • Float (float)- Used for a fractional number like 2.135
  • Boolean (bool) - Used for logical value like equal or not equal.
    such as && (logical and), || (logical or), and ! (logical not)

JavaScript allows three primitive data types:
numbers, strings, and boolean.

JavaScript also defines two trivial data types,
null and undefined, (each of which defines only a single value)

In addition to these primitive data types, JavaScript supports a composite data type known as object.
An object (that is, a member of the data type object) represents a collection of values (either primitive values, like numbers and strings, or composite values, like other objects).

Objects in JavaScript have a dual nature: an object can represent an unordered collection of named values or an ordered collection of numbered values. In the latter case, the object is called an array.

Although objects and arrays are fundamentally the same data type in JavaScript, they behave quite differently.

JavaScript defines another special kind of object, known as a function. A function is an object that has executable code associated with it. A function may be invoked to perform some kind of operation.

Number in JavaScript

The number is one of the data types of JavaScript that is used for representing values and also to represent and manipulate numbers like 0,1,2,3 or 100

The Number constructor contains constants and methods for working with numbers. Values of other types can be converted to numbers using the Number() function

Number Methods
Number(true); // returns 1
Number(false); // returns 0

String in JavaScript

Strings in JavaScript are sequences of Unicode characters, it stores a series of characters like “Abc or Def”. string can be declarer any text inside double or single quotes. it can be represented as:
const name1 = “Siddiky”;
const name2 = ‘siddiky’;

String Methods
search() - Searches a string for a specified value, or regular expression, and returns the position of the match
indexOf() - Returns the position of the first found occurrence of a specified value in a string.
match() - Searches a string for a match against a regular expression, and returns the matches.

Array in JavaScript

The Array object is used to store multiple values in a single variable:
It can be represented as:
const names = [“nur”, “alom”, “siddiky”];

Array Methods:
fill()- Fill the elements in an array with a static value.
filter()- Creates a new array with every element in an array that passes a test.
find()- Returns the value of the first element in an array that passes a test.
map()- Creates a new array with the result of calling a function for each array element.
pop() — Removes the last element of an array, and returns that element.
push()- Adds new elements to the end of an array, and returns the new length.

Object in JavaScript

JavaScript is designed on a simple object-based paradigm. An object is a collection of properties, and a property is an association between a name/key and a value.

In JavaScript, an object is a standalone entity, with properties and type.
Compare it with a car, For example. a car is an object, with properties. A car has a making year, a model, , etc.
In the same way, JavaScript objects can have properties, which define their characteristics.

var myCar = {
make: 'Ford',
model: 'Mustang',
year: 1969

Using a constructor function

Alternatively, we can create an object with these two steps:

  1. Define the object type by writing a constructor function. There is a strong convention, with good reason, to use a capital initial letter.
  2. Create an instance of the object with new.

To define an object type, create a function for the object type that specifies its name, properties, and methods. For example, suppose createing an object type for cars. This type of object to be called Car, and it to have properties for make, model, and year:

function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;

The use of “this” to assign values to the object’s properties based on the values passed to the function.

Functions in JavaScript

A JavaScript function is a block of code designed to perform a particular task. function can be defined using function keyword.

its build of following structure

  • The name of the function.
  • A list of parameters to the function, enclosed in parentheses and separated by commas.
  • The JavaScript statements that define the function, enclosed in curly brackets, {…}.
function square(number1, number2) {
return number1 * number2;

Function Return
When JavaScript reaches a return statement, the function will stop executing.
If the function was invoked from a statement, JavaScript will “return” to execute the code after the invoking statement.
Functions often compute a return value. The return value is “returned” back to the “caller”:

Calculate the product of two numbers, and return the result:

var x = myFunction(4, 3);   // Function is called, return value will end up in x

function myFunction(a, b) {
return a * b; // Function returns the product of a and b

The result in x will be: 12

JavaScript Condition

Conditional statements to control the program flow.

JavaScript includes the following forms of if-else conditions:

  1. if condition
  2. if-else condition
  3. else if condition
  4. switch condition

The if statement: “if” condition to specify a block of code to be executed if a specified condition is true.

if(condition expression)
// code to be executed if condition is true
///////////if( 1 > 0)
alert("1 is greater than 0");

if( 1 < 0)
alert("1 is less than 0");

if-else condition: Use “else” statement when you want to execute the code every time when if the condition evaluates to false.

if(condition expression)
//Execute this code..
//Execute this code..
//////var mySal = 500;
var yourSal = 1000;

if( mySal > yourSal)
alert("My Salary is greater than your salary");
alert("My Salary is less than or equal to your salary");

else if condition: Use “else if” condition when you want to apply the second level condition after the if statement. JavaScript allows multiple else if statements also.

if(condition expression)
//Execute this code block
else if(condition expression){
//Execute this code block
////////////////var mySal = 500;
var yourSal = 1000;

if( mySal > yourSal)
alert("My Salary is greater than your salary");
else if(mySal < yourSal)
alert("My Salary is less than your salary");

switch condition: The switch is a conditional statement like if statement. Switch is useful when you want to execute one of the multiple code blocks based on the return value of a specified expression.

switch(expression or literal value){
case 1:
//code to be executed
case 2:
//code to be executed
case n:
//code to be executed
//default code to be executed
//if none of the above case executed

Use the “break” keyword to stop the execution and exit from the switch.

switch statement contains an expression or literal value. An expression will return a value when evaluated. The switch can include multiple cases where each case represents a particular value.


The getDay() method returns the weekday as a number between 0 and 6.
This example uses the weekday number to calculate the weekday name:

switch (new Date().getDay()) {
case 0:
day = "Sunday";
case 1:
day = "Monday";
case 2:
day = "Tuesday";
case 3:
day = "Wednesday";
case 4:
day = "Thursday";
case 5:
day = "Friday";
case 6:
day = "Saturday";
The result of day will be: Today is Monday

Conditional (ternary) operator

The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy.

condition ? exprIfTrue : exprIfFalse
person.driver = person.age >=16 ? 'Yes' : 'No';

Using a conditional, like an if statement, allows us to specify that a certain block of code should be executed if a certain condition is met.

var age = 26;
var drink= (age >= 21) ? "Tea" : "Water";
// Output: "Tea"

A progressive JavaScript Developer and part time writer.