JavaScript Cheat Sheet: For a New Developer

JavaScript Cheat Sheet: For a New Developer
JavaScript Cheat Sheet: For a New Developer

Since its development, JavaScript evolved into a high-level, multi-paradigm, dynamic programming language. A major breakthrough for JavaScript was in 2009 when the cross-platform JavaScript runtime Node.js was released and it was enabled to run on the Server Side.

Post-this, in 2010 Google released AngularJS, it is a JavaScript-based Web development framework. And now, JavaScript is one of the most popular programming, scripting, and markup languages, running virtually everywhere: Mobile Devices, Cloud, Containers, Browser, Servers, Microcontrollers.

It is often regarded as the “undisputed king in Browser programming”. Because of the Node.js framework, JavaScript offers event-driven programming, which is highly suitable for heavy I/O tasks. In response to the high demand for the language, many developers intend to switch to JavaScript. Learning a new language is not that easy, the syntax varies at every stage. To assist beginners in learning JavaScript, we have prepared a Cheat Sheet below.

JavaScript Cheat Sheet

1. Data Types

There are seven data types in JavaScript :

The first six data types are primitive, and Objects are derived data types. 

  • String – represents a sequence of characters e.g. “hello”
  • Number – represents numeric values e.g. 100
  • Boolean – represents boolean value either false or true
  • Null – represents null i.e. no value at all
  • Undefined – represents an undefined value
  • Symbol – A “symbol” represents a unique identifier
  • Object
    • Array
    • Function

2. Basic Vocabulary

  • Variable: Any named reference to a given value is known as a variable.
  • Keyword / reserved word: Any word that forms the vocabulary of a programming language is called a keyword or a reserved word.
  • Operator: Operators are reserved words or mathematical symbols that perform an action on values and variables. Examples: +, – ,= ,*, , ===, typeof ,!= and so on
  • Statement: A group of words, numbers or operators that perform a specific task is known as a statement. var b = q

3. Object

An object is a user-defined or derived data type in JavaScript used for storing sets of data in elementary key-value pairs. 

4. Function

A function is a block of code grouped as a separate section. This block of code is executed only when the function is explicitly called. Functions allow users to organise codes into sections and enables code reusability.

A function is operated by two steps:

  • Declaring/defining a function.
  • Making functions calls when required.

Image Source: Programiz

5. Variables and their scope

There are two rules that align the scope of a variable:

  • Variables declared in the outer scope can be accessed by the inner loop. While the variables declared in the nested loop cannot be accessed by the outer scope.
  • Variables are taken up from the specific lexical environment.

Image Source: medium

6. Operators

The commonly used JavaScript operators are given in the table below:

Image Source: National School Of Opening Schooling

  • Operator Precedence: If there is more than one operator in an expression, the order in which they will be executed is determined by the “Operator Precedence”. Operators with higher precedence are executed first.
  • Operator Associativity: If two or more operators have the same precedence, then the “Associativity” table tells us about the direction in which the code will be parsed.

7. Coercion

If the user attempts to compare two or more different “types”, the JavaScript engine converts one of them into another, so that the two values can be compared. The deciding parameter is the Type coercion priority.

Type coercion priority order in JavaScript:

  • String
  • Number
  • Boolean

8. Truthy and Falsy

A few values in JavaScript return true when they are coerced into boolean. These values are known as truthy values. While, on the other hand, a few values return false, if coerced into Boolean. These values are known as falsy values. Go through some of the examples in the image given below.

Image Source: Slide Share

9. Creating Variables

The user has three options for creating a JavaScript Variable :

  • Variables declared with var type are in the scope of function, they can be used as Global variables, only if declared so.
  • let variables are limited to block scope only.
  • const variables are let variables whose values can’t be assigned.

Image Source:

10. Looping Events

Two statements in javascript can not be executed parallelly. Execution takes place line by line, each JavaScript statement is synchronous and enables blocking.

Image Source: Medium

11. Browser

A web browser is a high computing piece of software that comes with abundant components. These components assist web developers to create complex web-based applications. To maintain security, web developers are restricted to use some of these components.

For example, A web developer is allowed to keep a track of a user’s location but he/she can’t save their login credentials.

Image Source:

12. DOM – Document Object Model

The Document Object Model (DOM) is a programming interface mainly used for HTML and XML documents. It represents the page so that programs can change the document structure, style and content. The DOM is popularly known as an object-oriented representation of the web page, that can be modified with the help of a powerful scripting language such as JavaScript.

Image Source:

13. Auto-Inherited Properties

By default, JavaScript values inherited certain properties. This happens because every type comes with a constructor that has certain special properties known as a prototype. All the methods that come with a prototype are inherited by default, by the new type value.

For example:

  • .concat()
  • .charAt()
  • .split()
  • .slice()
  • .toFixed()
  • .toString()
  • .find()
  • .every()
  • .some()
  • .sort()

14. Built-In Objects

There are a bunch of in-built objects that make coding easy. The Date and Math objects find a wide application on a regular basis.

For Example:

  • Math.sqrt(36) // 6
  • Math.min(7, 4, 6) // 4
  • Math.max(7, 4, 6) // 7
  • Math.random()

15. Promise

An object that provides a useful construct while working with asynchronous tasks is known as a promise. It is known as a “Promise”, as it ensures that it will run during successful execution or failure of a specific task.

For working with a promise you need to:

  • Create a promise
  • Use a promise

Frequently Asked Questions

How do I turn on JavaScript?

1.Go to settings and click on the “Internet Options” window.
2. From it select the Security tab.
3. On the “Security” tab, make sure that you select the Internet Zone.
4. Click on the “Custom level.” button.
5. Then go to Security Settings.
6. The Internet Zone dialog box appears.
7. Enable for Active Scripting from the Scripting section.

What JavaScript is used for?

JavaScript is mainly used for adding dynamic elements to the web page. It is also used for adding special effects that is used for turning web pages interactive and engaging the user. It can be used at the client-end as well as the server-end. It is primarily used on websites for validation purposes. Many complex actions and calculations can be easily carried out by JavaScript.

How do I enable JavaScript on Google Chrome?

For enabling JavaScript in Google Chrome:
1. Open Google Chrome on the target computer.
2. On the top right corner, click More option and then select Settings.
3. Click on Privacy and Security.
4. Select Site Settings.
5. Select JavaScript from the available options.
6. Turn on ALLOWED.

Is JavaScript a programming language?

Yes, JavaScript is acknowledged as a dynamic computer programming language. It is a lightweight language, used mostly as parts of web pages. Generally, the implementations of these web pages are used for building client-side scripts for interacting with the user and creating dynamic pages. It comes with object-oriented capabilities and is an interpreted programming language.


You can’t write codes or create projects using any programming language unless you are familiar with its building blocks. Although, the basic structure of all the programming language is the same yet the syntax varies highly. That’s why first learn about the syntax by writing elementary codes and then use the language for writing codes or creating projects.

JavaScript was conventionally used for scripting but nowadays, it is also used for robust development activities. Many apps can also be created single-handedly using JavaScript. The language is highly in demand and offers a promising career. Therefore, we highly recommend you go through the cheat sheet for getting your hands-on JavaScript.

By Vanshika Singolia