Fundamentals that you should know about JavaScript as a Developer

Introduction to JavaScript

01) Introduction to JavaScript

JavaScript was invented by @BrendanEich in 1995 and became an ECMA standard in 1997. JavaScript is one of the most popular functional and asynchronous languages over object-oriented languages.

  • JavaScript is a scripting language that is both lightweight and cross-platform. It is well-known for creating online pages, but it is also used in a variety of non-browser applications. Client-side and server-side programming are both possible with JavaScript. JavaScript has a basic set of language components including operators, control structures, and statements, as well as a standard library of objects like Array, Date, and Math.
  • JavaScript programs are run using a single thread and can run on a browser, server, database, microcontroller which means actually it can run on anywhere. Since it has ways to create new threads JavaScript is considered as a single-threaded language.
  • When execution happens JavaScript does not wait for the I/O operations to get completed, instead of that, it continues their program execution that’s why we called it as non-blocking I/O.
  • Because of this non-blocking I/O JavaScript is asynchronous. In runtime, JavaScript is actually a dynamically typed programming language but it determines variable types and ordering in runtime.
  • As a programming language JavaScript supports both object-oriented programming with prototypal inheritance as well as functional programming therefore, it is referred as a multi-paradigm programming language. Especially JavaScript has an eventing system that manages its asynchronous operations.
  • Client-side : It provides objects that allow a browser and its Document Object Model to be controlled (DOM). If client-side extensions allowed a program to add components on an HTML form and respond to user actions like mouse clicks, form input, and page navigation, that would be awesome. AngularJS, ReactJS, VueJS, and many more client-side frameworks are useful.
  • Server-side : It provides items necessary for executing JavaScript on a server. For example, if server-side extensions allow an application to interface with a database and give information continuity from one program invocation to the next, or execute server-side file operations.
    Node.js is a handy framework that is currently the most popular.
What is JavaScript

02) Classes, Objects, and Prototype

ECMAScript 2015, also known as ES6, introduced JavaScript Classes. A JavaScript class is not an object. It is a template for JavaScript objects and they are encapsulate data with code to work on that data.

  • In JavaScript, a constructor function is used with the new keyword when creating an object. When a function is used with the new keyword that function just acts as a JavaScript class. By default, JavaScript has introduced the class keyword but it does not yet adopt by all JavaScript engines.
  • JavaScript still uses a prototype-based inheritance model. JavaScript Classes are syntactic sugar over the prototype-based inheritance model which we use to implement object-oriented programming concepts.
  • Before using classes, we used constructor functions to do object-oriented programming in JavaScript. A constructor function is just another function. When new keyword is used the new object is created and it is assigned as this for the duration of the call to the constructor function.

In JavaScript, objects are king. If you can understand objects properly, then you are able to understand JavaScript as well.

  • A JavaScript object is an entity that has state and behavior simply we can say properties and methods. As an example car, chair, glass, keyboard, monitor, etc. JavaScript is an object-based language. In JavaScript, everything is an object. JavaScript is template based not class-based. Here, we do not create a class to get the object. But, we create objects directly.
Classes and Objects in JS

JavaScript function has a reference to another object is referred to as a prototype. In other languages, it is somewhat similar to a class definition.

  • We can use prototype objects when we create objects for inheritance and add methods to a JavaScript class. Basically, a prototype is really another object instance. Because of the flexibility in JavaScript, there are many ways to create classes as well as to extend classes. So we can recommend a prototype to do so.
  • A Function that is being used to create objects is called a constructor function. The Functions prototype is used to inherit properties to object instances.
  • Object instance also has a prototype and it is basically the object instance from which object is being created. Object ‘__proto__’ is where an object gets its properties inherited from.
Prototype in JS

03) How "this” keyword act

JavaScript’s this keyword is one of the hardest aspects of the language to grasping. But it is critically important for writing more advanced JavaScript code.

In JavaScript, the this keyword uses :

  • this keyword is able to identify the object in the current execution context when we invoke a method.
  • The this keyword is associated with JavaScript functions. When it comes to this, the basic fundamental thing is to understand where a function is invoked. Because we do not know what is in the this keyword until the function is invoked.
  • The usage of this can be divided into five different binding aspects. Inside an object ‘this’ refers to the object itself that inside it. In addition to that other languages in JavaScript, ‘this’ keyword acts differently. This behavior is actually very noticeable in callbacks and closures.
  • In global context ‘this’ refers to the global object when simply say in the browser it is the window object. This behavior will get changed into strict mode.
  • If a function in JavaScript that is using ‘this’ keyword is being passed to another object then ‘this’ will refer to that object, but not to the original object.
This Keyword in JS

04) Strict notation

The "strict" notation was new in ECMAScript version 5. Actually, it is not a statement, but it is a literal expression, ignored by earlier versions of JavaScript.

  • The purpose of "strict" is to indicate that the code should be executed using "strict mode". Strict notation is the restricted mode of JavaScript. The purpose of having this strict notation is that it makes it easier to write secure JavaScript programs.
  • Strict mode makes some sense for bad practices in JavaScript to errors. It is good enough to keep developers away from using syntaxes that will get invalidated with future JavaScript developments.
  • For example, strict notation does not allow to create variables without the var keyword that means variables have to be declared. Another example would be strict notation will stop referring to the window object as ‘this’ from outside object instances.
Strict Keyword in JS

In JavaScript, a closure is a function that allows variables in the outer scope from its inner scope. The closure was able to keep the outer scope inside its inner scope.

  • JavaScript closure is simply referred to as a function that returns another function.
  • In JavaScript closure is used to encapsulate variables into a function and it will restrict access to function from its outside.
  • JavaScript creates a better environment with all the local variables from the outer function when the inner function is created. The closure is basically a combination of this environment and the inner function.
Function Closure in JS

06) Callbacks and Promises

JavaScript is asynchronous. All input-output operations in JavaScript is implemented to be asynchronous by nature.

That means asynchronous code permits the program to be executed immediately, whereas synchronous code prevents the remaining code from being executed until the current one is completed.

Callbacks and Promises in JS

Now let’s go through a simple understanding about version controlling...!

What is Version Controlling and Why we use it?

  • Easy collaborative development
  • Overview of changes performed to a file
  • Access control
  • Conflict resolvement
Git Commands



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store