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 …
Tag Archives: Coding
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”
Different ways to Iterate through Map in Java
Learn different ways to iterate through Map object in Java. Image from unsplash Let’s create a Map Map<String , String> fruits = new HashMap<>(); fruits.put(“apple” , “🍏” ); fruits.put(“banana” , “🍌” ); fruits.put(“grapes”, ” 🍇 “); Method 1 : Java 8 forEach method fruits.forEach( (k, v) -> System.out.println(“Key : ” + k + ” value : ” + …
Continue reading “Different ways to Iterate through Map in Java”
Creating Dice in Flexbox in CSS
Learn how to create dice in CSS using flexbox Dice created with flexbox in CSS First Face First face of the div Our first-face of the die will have one dot at the center. <div class=”dice first-face”> <span class=”dot”> </span> </div> Here, we have the dice– and dot-classed elements. Now we can add some CSS to the die. …
Understanding Switch Statements in JavaScript
Image from negative space Whenever we are in situation of writing multiple if/else statement for a particular test case, then the multiple if/else statement can be replaced by switch statement. Syntax : switch(expression_or_value) {case expression_or_value : operation1 [break]; case expression_or_value : operation2 [break]; … default : default operation [break]; } // break is optional A switch statement …
Continue reading “Understanding Switch Statements in JavaScript”
Insert an element in specific index in JavaScript Array.
Learn how to insert an element in specific index in array. Image from unsplash (Zdennek) We have some in-built methods to add at elements at the beginning and end of the array. push(value) → Add an element to the end of the array. unshift(value) → Add an element to the beginning of an array. To add …
Continue reading “Insert an element in specific index in JavaScript Array.”
Master Destructing Values in JavaScript
Learn how to destructure array and object properties into variables in JavaScript. Image from Unsplash The destructing syntax allows us to extract multiple values based on the property name from objects or arrays. // Destructing arrayvar num = [1,2,3,4,5]; var [a, b] = num; console.log(a, b); //1,2 // Destructing Object var obj = { name : …
Essential DOM Operations with JavaScript
Learn about some basic but essential DOM methods in JavaScript Image by Pankaj Patel from Unsplash The below code is what we’ll use to access and manipulate with our JavaScript DOM methods: <div id=”parent”> <div class=”child one”> < /div> <div class=”child children second”> < /div> <div class=”child third”> < /div></div> Select and element by id. It …
An Overview of Array Methods in JavaScript
Learn about how to manipulate arrays in JavaScript Image by PaweĹ‚ CzerwiĹ„ski from Unsplash Let’s create an array: var numbers = [1,2,3,4,5] Array elements are accessed using an index. The index starts from 0 . So if we want to access the first element, then we need to access using index 0. numbers[0] // 1 numbers[3] // …
Continue reading “An Overview of Array Methods in JavaScript”
Console cheat sheet for JavaScript developers
Learn how to use the browser console effectively for debugging Image by Ilya Pavlov from Unsplash You can open console by using: Chrome → Ctrl Shift J (on Windows) or Cmd Option J (on Mac) Safari → Option-Cmd-C The console object provides access to the browser’s debugging console. The console object present in the global scope. …
Continue reading “Console cheat sheet for JavaScript developers”