Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • JS Tutorial
  • JS Exercise
  • JS Interview Questions
  • JS Array
  • JS String
  • JS Object
  • JS Operator
  • JS Date
  • JS Error
  • JS Projects
  • JS Set
  • JS Map
  • JS RegExp
  • JS Math
  • JS Number
  • JS Boolean
  • JS Examples
  • JS Free JS Course
  • JS A to Z Guide
  • JS Formatter
Open In App
Next Article:
What is backend Developer
Next article icon

Advanced JavaScript Backend Basics

Last Updated : 22 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

Getting Started with JavaScript Backend Basics The following article is a continuation to my previous article. In this article, we will dive deep into some of the advanced JavaScript concepts that are being used widely in the industry.

“==” vs “===”

  • The “==” coerces the types of the input that is it forces the variable to be the same and then checks their equality.
  • The “===” actually requires equivalent types to give a true output. Basically, the “===” is more widely used and the “==” should only be used when we really know the type equivalence of the inputs. Below is the table that clearly defines for what values they both will send TRUE or FALSE.

11 Note: My suggestion would be to always use “===” unless you really know what you are doing.

JavaScript false values

The following values when converted into boolean are treated as FALSE values:

  • 0 – The number zero is always false
  • undefined – Any value if primitively undefined is treated as false.
  • null – Primitive null values are always false
  • +0 , -0 , NaN(not a number) – positive/negative zero or a value which is Not a number is considered false.

JavaScript Truth Values

The following values when converted into boolean are treated as TRUE values:

  • { } – The empty object
  •  [ ] – The empty array
  • Everything else that is not false is TRUE.

Prototypical inheritance

We know that everything in JavaScript is an object except the primitive types so we require a way to differentiate between objects and the other data types. Here comes the concept of prototypical inheritance.

  • The Non Primitive types (Objects) have a few properties/methods associated with them. Example:- Array.prototype.push() String.prototype.toUpperCase()
  • Each object stores a reference to its prototype and then maybe its prototype also has its prototype that is prototype chaining might be possible.
  • The prototype/ properties/ methods defined most tightly to the instance have priority.

Example: 

javascript




let arr = [];
arr.test = 'test'; // making a property called test
Array.prototype.test = 'test1' // making a prototype test on the array object
 
 

Now if we print “arr.test” on our console.

 Output :

test

The reason is that test is tightly bound first to the array instance and has priority even though we defined a prototype “test1” later.

Prototype Chain

NULL<—Object<—Array<—Instances of Array The above represents an example of prototype chain followed in case of objects. Like prototype of all instances of array is the object array, the prototype of array object is Object and since in JavaScript everything is an Object and hence its prototype is NULL. Some methods or prototypes has a method ‘writable’ which is set to false i.e. they can’t be overwritten. Example: 

javascript




let arr = [1, 2, 3];
arr.length = 'test'; //length is also an actual property of array and not writable
 
 

The above program gives no error but when we print arr.length, the output is “3” which is the actual property and not what we created. Note:- We know that primitive types have no methods associated with them but most primitive types have object wrappers which we can declare and then we can use those methods and properties. JavaScript will box or wrap the primitive values so that you can have access to the methods which the non primitive types use. The following list defines the different wrappers in JavaScript:

  • String()
  • Boolean()
  • Number()
  • Object()
  • Symbol()

Note: Please make sure you see the difference between these and the primitive types that in the above wrappers, all the first characters of the name of the wrapper is capitalized. Example:- 14 The above line errors since 50 is a primitive type that is a ‘number’ and has no methods. But in the below example, 15

The JavaScript engine wraps the primitive type ‘x’ by assuming the Number() object wrapper. So now since it wraps the ‘x’ into Number() prototype which is an object and now we can use the functions that were not accessible to us.

The Global Object

All the variables and functions are actually parameters and methods defined on the global object. For a browser, the global object is the ‘window’ object. For NodeJS, the global object is called ‘global’ itself. Below is an image of both the global objects on the browser and nodeJS engine. 16 The list shows all the browser global object ‘window’ functions defined which can be used by JavaScript. 17 The list shows all the nodeJS global object ‘global’ functions defined which can be used by JavaScript.

Execution context

  • This is equivalent to a “Stack Frame” in C.
  • Wrapper of variables and functions are local to a function creation.
  • Collection of execution contexts is known as execution stack.

Lexical Environment

  • It determines how variable names are resolved especially with nested functions.
  • Child functions contain the scope of the parent function even if the parent has returned. (This part will be covered later in the topic “closures”)

Example:- 

javascript




let x = 50;
function test() {
      var x = 42;
      function printvaluex(){
             console.log(x);
     }
}
 
 

The child function is in scope of test even though there is a global ‘x’ present. This is due to the fact that the lexical environment of the child function is in a closure to its parent and not to the global value ‘x’. 



Next Article
What is backend Developer

A

Anirudh Acharya
Improve
Article Tags :
  • JavaScript
  • Web Technologies

Similar Reads

  • Advanced JavaScript Backend Basics
    Getting Started with JavaScript Backend Basics The following article is a continuation to my previous article. In this article, we will dive deep into some of the advanced JavaScript concepts that are being used widely in the industry. "==" vs "===" The "==" coerces the types of the input that is it
    5 min read
  • What is backend Developer
    Backend developers are a crucial part of modern web development teams, responsible for building the server-side logic and infrastructure that powers web applications. In this comprehensive article, we'll see the role of a backend developer, covering various aspects such as responsibilities, skills r
    5 min read
  • What is Backend Development? Skills, Salary and Roles
    Backend development is a blessing to all of us that we are able to get everything done by just sitting at home. Be it booking tickets, watching movies, or any sort of thing, backend development plays a major role in building an application. It is also one of the highly demanding professions in the I
    7 min read
  • Advantages and Disadvantages of JavaScript
    JavaScript is an interpreted programming as well as a scripting language. Many of these are related to the way, JavaScript is often executed directly in a client's browser commonly utilized in web development. It was originally developed by Netscape as a way to feature dynamic and interactive elemen
    3 min read
  • Difference between Node.js and JavaScript
    JavaScript and Node.js are both crucial in modern web development, but they serve different purposes and are used in different environments. JavaScript is a programming language primarily used for client-side web development, while Node is a runtime environment that allows JavaScript to be executed
    3 min read
  • How to Use Node.js for Backend Web Development?
    In the world of website design nowadays, NodeJS is a supportive tool for making capable backend systems. Whether you are an experienced web designer or just beginning out, NodeJS can upgrade your aptitude and help you in building extraordinary websites. This guide will show you how to use NodeJS to
    8 min read
  • Top 10 Backend Technologies You Must Know
    To provide any responsive and effective software solution, frontend, and backend are the two most essential technologies that work together. A back-end framework is used to create server-side web architectures stably and efficiently. Backend technologies focus on improving the hidden aspects of the
    11 min read
  • 10 Best Backend JavaScript Frameworks in 2025
    When JavaScript was first created, it used to run only in the browser of the client (user). At that time, it was sufficient, as websites used to be static and just displayed some information for the user to see and read. But as both time and technology moved forward, web development changed. Soon, t
    11 min read
  • Good Coding Practices For Backend Developers
    API, Authentication, Design Patterns, MVC, Cache, Cookies, Sessions, JSON, Endpoints, Server, Hosting, Postman, CRUD, Curl... Aren't all these words familiar to you??? If yes, then surely you're a backend developer or working on the backend part of the application.  Clients often underestimate the w
    9 min read
  • 12 Backend Development Tools For Web Developers
    While Frontend Web Development is concerned with the designing of the user interface of the website using web technologies like HTML, CSS, JavaScript, etc. - Backend Web Development (or you can say Server-Side Development) is responsible for the appropriate functioning of the website. In simple word
    9 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences