1. javaScript

Fundamentals of JavaScript Language

Like a usual language which people speak let’s say English, there are a number of factors/rules/guidelines involved in forming a sentence, similarly for Programming Languages as well there does exist certain rules.

Most commonly these basic rules of a specific programming language are called Lexcial Structure of that langauge. Most of languages out there have a specific/unique lexical structure based upon which code is written using that Programming Language.

In order to better understand JavaScript, first step should be to learn it’s Lexical Structure and become familiar with fundamentals of JavaScript. Then move on to build large scale software/code base.

Lexical structure of a programming language is the set of elementary rules that specifies how to write programs using that language. It’s lowest level syntax of language, specifying things like how does variables look like in language.

Lexical Structure of JavaScript

Let’s see what’s Lexical Structure of JavaScript and what’s basic grammar rules for writing javaScript code.

Character Set

JavaScript programs are written using Unicode character set, which is superset of ASCII, Latin-1 and it does support every language used nowadays on the planet.

Case Sensitivty

JavaScript is a case sensitive language, that’s why you need to be careful when declaring variables/function names. For example – onClick and onclick are two different keywords in javaScript.

So always try to double check whenever your using one variable name again and again in the code. Otherwise when you run the code, you may see errors like ‘Variable not defined’.

Formatting JavaScript Code

Writing lines of code without any spaces or tabs would still be fine, as JavaScript Engine while converting code into machine code just ignore whitespaces/tabs. But it’s always good to have properly indented/formatted code as it improves readability.


In any programming language, for better understanding of code or while your working in a team. Then comments in code are only thing which could help other person to understand different aspects in code easily. JavaScript have two types of comments –

  • Single line comment( //This is a comment)
  • Multiple Lines comment( /*This is a comment*/ )


In any programming language, a literal is a fixed data value like a constant in Maths. Literals could be assigned to declared variables in a programming language. For example – 10, 1.34, “Computer Science Hub” are all literals in JavaScript.


For writing code in any programming language, there need to be certain guidelines around who variables/functions should be declared.

Otherwise there will be a lot of conflict between Programmer Declared Entities and inbuilt language keywords. Inbuilt keywords of a programming language are called Reserved Words; best practice should be avoid using these keywords for declaring variables/functions.

Indetifiers/Keywords are simple names in a programming languages, in javaScript these should start with a letter, underscore(_) or dollar sign only. For example – i, $i are correct declared Identifiers; whilst 34Computer is not.

Reserved Words in JavaScript

In JavaScript there are certain words which cannot be used by programmer as there words are used internally by language.

So you should avoid using these reserved words as variable decelerations.

Reserved Words in JavaScript

Only not these are some of common words, which are reserved. There does exist many other words, global variables and functions, use of which should be avoided by programmer. Here is the table containing all of those –

Reserved Words Global Variables and Functions

Optional Semicolons in JavaScript

JavaScript specifically doesn’t enforce to use semicolons at end of each statement, but you could use it if you want. Moreover in case at end of a statement you don’t insert semicolon then JavaScript Engine would automatically do that before converting JS to machine code.

So technically in javaScript it’s just upto programmer whether to use Semicolon or not. But personally I do like inserting semicolon; just to make code look nice and make it more readable for other people.

Anyway a = 3 and a = 3; are same in JavaScript.

Data Types, Variables in JavaScript

Every entity in JavaScript is always of a certain type, that could be Number or String. JavaScript have two primitive and object types(collection of primitive types like array, functions in Object-Oriented JavaScript Programming)

Primitive Types in JavaScript

  • boolean
  • null
  • undefined
  • number
  • bigInt
  • string
  • symbol
  • normal objects/Functions

In javaScript you can declare variable names and assign these a value.

Variables in javaScript are defined as symbolic name for a value to refer that value later in the program. Like a = 3; here a is a variable assigned value 3.

Boolean in JavaScript

A Boolean in Logic Maths represents truth or falsehood of a value. Boolean could either be true or false only. Similarly in JavaScript a boolean variable could only hold two values – true or false. Boolean is very helpful for structuring JavaScript code properly and control flow of code while program runs.

To know more about how Booleans are used in JavaScript Programming Language you can check out – Boolean in JavaScript on this website. In that article I’ve explained everything.

Functions in JavaScript

In JavaScript, a function is a special object which has executable code in it, this function can be invoked to run and may return some output as well.

What are functions in javaScript programming language
Simple example of functions in JavaScript Programming Language

Classes in JavaScript

Classes in javaScript can be considered as subtype of Object Primitive Type, these could be used for making up Objects. Like built in JavaScript class Date can be utilized for making Date Objects. Not only classes can make object but rather these could have certain functions related to objects created by them as well. Below is an example of Vehicle Class which can be used for creating Vehicle Object by specifying make, model, color of car and then we can also ask newly created Object about its specifications by calling make(), model(), color() functions.

Showing what are classes in JavaScript programming language with an example
Classes in JavaScript Programming Language

Strings in JavaScript

In JavaScript, a string is an immutable ordered sequence of 16-bit values where each of bit represents a Unicode Character and combination of these strings is used for representing text.

For dealing with different aspects of Strings in JavaScript, I’ve put together a complete article explaining everything you can check that out – Strings in JavaScript Computer Science Hub.

What are Objects in JavaScript?

An object in JavaScript is a collection of properties where each property has a name and an associated value(this could either to primitive or not).

w3Schools have this cool looking example for JavaScript Object.

JavaScript Objects

Note – In javaScript some special type of objects are known as Global Objects.

Constructors in JavaScript

In JavaScript, functions which are used for initialising a newly created object are Constructors. Let’s understand this concept with an example –

  • Using inside Classes
Using constructor() in JavaScript Class
  • Using constructor for initialising a Class Object
Making new objects in JavaScript from class using new keyword
Using new keyword for constructing object in JavaScript

Most often in JavaScript code ‘new’ keyword code line is considered a Constructor.

Methods in JavaScript

JavaScript methods are actions which can be performed on an object or it can be a property of an object containing some function.

Methods in JavaScript programming langauge
JavaScript Object having function as value for it’s one of property

Memory Mangement in JavaScript

The JavaScript Interpreter performs automatic Garbage Collection for doing Memory Management meaning as a programmer you don’t need to worry about destruction of objects/deallocation of memory occupied by objects. Rather when interpreter finds that a specific object would no longer be required in future for execution of code, then it just automatically reclaims memory occupied by that object.

So as a programmer you don’t need to worry about heap/stack in memory. JavaScript is already smart enough to do this stuff.


JavaScript is booming nowadays so better to learn it and jump into Software Industry as JavaScript Developer.

I hope that you find this kind of starter guide for JavaScript Programming Language useful. But in case if you want me to clarify anything or in general you want to just ask something about JavaScript to me, then comment section door is open for you. Just leave a comment and I would reply as soon as possible for me.

Moreover on this website Computer Science Hub, I’ve other articles about JavaScript as well in case you want to learn more about JavaScript. So do check those out – JavaScript Computer Science Hub.

Comments to: Fundamentals of JavaScript Language

Your email address will not be published.