Sitemap
Dilini Navodya

Dilini Navodya

JavaScript

3 min readMar 17, 2022

--

In this article, we’ll go over the fundamentals of JavaScript.

Press enter or click to view image in full size

JavaScript is a dynamic programming language used for web development. It can be used on both the client-side and server-side to make web pages interactive.

JavaScript’s name was changed several times at first:

Its code name was Mocha.

It was known as LiveScript in the Netscape Navigator 2.0 betas (September 1995).

It was given its final name, JavaScript, in Netscape Navigator 2.0 beta 3 (December 1995).

Why is JavaScript used?

Because they include built-in execution environments, all popular web browsers support JavaScript.

JavaScript is a weakly typed programming language in which certain types are implicitly cast (depending on the operation).

JavaScript is an object-oriented programming language that uses prototypes for inheritance rather than classes.

It is a simple and interpreted language.

Data Types in JavaScript

In JavaScript, data types describe the various types of data that you will be working with and storing in variables. It’s essential to know each of these data types because otherwise, data can be stored incorrectly, causing problems in your code later on.

Press enter or click to view image in full size

var / let / const in JavaScript

var

Variable refers to anything that can change. A variable in JavaScript stores the data value that can be changed later. To declare a variable in JavaScript, use the reserved keyword var.

Let

It is not possible to redeclare. Before using let, it must be declared. Let’s talk about Block Scope.

const

Get Dilini Navodya’s stories in your inbox

Join Medium for free to get updates from this writer.

Redeclaring const is not possible. The variable const cannot be reassigned. Const has the Block Scope property. JavaScript Data Types

Arithmetic Operation in JavaScript

Arithmetic operators perform arithmetic on numbers

Press enter or click to view image in full size

JavaScript Functions

A JavaScript function is a block of code designed to perform a particular task. It is defined with the function keyword, followed by a name, followed by parentheses ().

There are mainly two advantages of JavaScript functions.

  1. Code reusability: We can call a function several times so it save coding.
  2. Less coding: It makes our program compact. We don’t need to write many lines of code each time to perform a common task.

There are 3 types of functions in JavaScript:

  • Named function
  • Anonymous function
  • Arrow functions.

Arrow functions improve the readability and structure of your code. Arrow functions are essentially anonymous functions (the functions without a name and not bound with an identifier). They have no return value and can be declared without the function keyword.

JavaScript Objects

A JavaScript object is an entity having state and behavior (properties and method). JavaScript is an object-based language. Everything is an object in JavaScript.

There are 3 ways to create objects.

  1. By object literal
  2. By creating instance of Object directly (using new keyword)
  3. By using an object constructor (using new keyword)

JavaScript Classes

Classes are a subset of functions in JavaScript. The class can be defined in the same way that function declarations and function expressions are.
Within the body of the JavaScript class, there are various class members such as methods and constructors. The class runs in strict mode. As a result, the code that contains the silent error or mistake throws an error.

So far, we’ve gone over the fundamentals of JavaScript as well as their most common fundamentals through code examples. This knowledge will be useful in the future to comprehend JavaScript frameworks.

Thank You.

--

--