They’re like arrays with more structure and rules Image by Brooke Lark from Unsplash Stacks are data structures that follow the Last-In-First-Out (LIFO) principle, meaning the last item inserted into a stack is the first one to be deleted. In other words, a stack is a list of elements that are accessible only from one end of …
Tag Archives: javascript
Six Ways to Create Objects in JavaScript
Learn six different ways to create an object in JavaScript. image by Dawid ZawiĹ‚a There are multiple ways to create Object in Javascript, I have listed six of them which I learned while reading. So I would like to share that with all JavaScript geeks here. First Way → Using Assignment This is how most of …
Implementing a Queue in JavaScript
A look at the queue data structure Image by Levi Jones on UnSplash A queue is a list — similar to the real world queue. The one who gets into the queue first is the one who is removed first from the queue. Technically speaking, this process is called first in, first out (FIFO). The element which is …
Different ways to remove elements from an array in JavaScript
Image by Michael Dziedzic From UnSplash 1. Using the pop method Array.pop will delete the last element of an array. var array = [1,2,3,4,5]; array.pop(); array; // [1,2,3,4] array.pop(); array; // [1,2,3] 2. Using the shift method Array.shift will delete the first element of an array. var array = [1,2,3,4,5]; array.shift(); array; // [2,3,4,5] array.shift(); array; // [3,4,5] …
Continue reading “Different ways to remove elements from an array in JavaScript”
Using the every() and some() methods of Array in JavaScript
Learn how to use every and some method in JavaScript. every → Checks if all elements of the array satisfies the provided callback function some → Checks if any one of element in the array satisfies the provided callback function every The every method will take a testing function as an argument, all the element …
Continue reading “Using the every() and some() methods of Array in JavaScript”
In-Depth Introduction to Call Stack in JavaScript.
Learn how the function executed in JavaScript. Image from Eaters Collective What is Stack ? Stack is a Data structure, which is similar to an array, except that we cannot access the elements using the index directly and we can only insert and delete elements at the Top of Stack(ToS). We majorly perform 2 operations in …
Continue reading “In-Depth Introduction to Call Stack in JavaScript.”
Removing jQuery From Your Project With JavaScript: Part 1
Learn to replace the jQuery DOM operation with JavaScript Photo by Sagar Patil on Unsplash The reasons for removing jQuery are: To get native performance To understand what’s happening inside jQuery functions so we can decide whether we go for jQuery or JavaScript Part 1 of this series only focuses on getting elements without using jQuery. …
Continue reading “Removing jQuery From Your Project With JavaScript: Part 1”
Creating a PDF Viewer in JavaScript
Learn how to create a PDF viewer in Javascript using PDF.js PDF.js is a JavaScript library maintained by Mozilla and designed for handling PDFs in JavaScript. Implementing PDF js We are going to create a PDF viewer which will have the following functionality: View a PDF Go to the next page Go to the previous page Go …
Implementing Set functionality in JavaScript
Learn how to implement union ,intersection , difference , symmetricDifference in JavaScript. Image from Javier Quesada The Set object lets you store unique values of any type, whether primitive values or object references. Example var array = [1,2,3,4,4,5]; var set = new Set(array); set; // Set(5) {1, 2, 3, 4, 5} duplicates are removed The detailed introduction to Set …
Continue reading “Implementing Set functionality in JavaScript”
Detecting Online/Offline Status in Javascript
Learn how to detect if the user is online or offline and handle events if a change in the online/offline state occurs. We can detect if the user is online or offline by using the online property on the navigator object which will return true if the user is connected to the internet, otherwise it returns …
Continue reading “Detecting Online/Offline Status in Javascript”