JavaScript at it’s finest

jQuery

jQuery is a JavaScript library designed to simplify HTML DOM tree traversal and manipulation, as well as event handling, CSS animation, and Ajax. It’s basically used to connect with HTML elements in the browser via the DOM. The Document Object Model is the method by which Javascript and jQuery interact with the HTML in the browser.

JavaScript Prototype

Javascript only has one construct: objects. All JavaScript objects inherit properties and methods from a prototype:

Data objects inherit from Data.prototype
Array objects inherit from Array.prototype
People object inherit from People.prototype

JavaScript(ES6) Class

Classes are basically syntactical sugar over JavaScript’s existing prototype-based inheritance. It’s a blueprint from which individual objects are created. Classes provide a simpler and clearer syntax to create objects and deal with inheritance. One way to define a class is by using a class declaration. A class can also be defined by a class expression. Class expressions can be either named or unnamed. The name given to a named class expression is local to the classes body.

named class: var puppy = class Dog {
constructor(name, age) {
this.name = name;
this.age = age;
}
};
unnamed class: var cat = class {
constructor(name, age) {
this.name = name;
this.age = age;
}
};

JavaScript Scope

The scope of a variable or a constant determines where that constant/variable is accessible . Variables that are declared by let or const; the scope is limited to the block in which they are defined.

function start() { 
const message = "Hello World";
}

JavaScript Nested Function

Creating a function inside another function is called nested functions in javascript. A function will always have access to the outer scope.

The Module Pattern

The Module design pattern is one of the most used design patterns for keeping particular pieces of code independent from each other. Modules allow programmers to break up different parts of code to make it easier to maintain and reason about. Modules can also provide encapsulation which can protect properties and functions from being accessed from other parts of the code.

Hoisting

Variable declarations and function declarations are processed before any code is executed. Declaring a variable or a function anywhere in the code is equivalent to declaring it at the top. This means that a variable and functions can be used before they are declared. This behavior is called hoisting. The declaration is moved to the top. Variable definitions are when you assign a value to a variable, which aren’t hoisted to the top.

Callback Function

Call backs are tremendously useful and give programmers a lot of flexibility as well as extendability. JavaScript allows you to define functions as variables. They are no different than any other objects. The only difference is that you can invoke them. This allows programmers can take advantage of the feature of the language to pass them around and allow us to gain some flexibility.

--

--

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