Posts about "JavaScript"

Deep copying objects using JSON.stringify and JSON.parse

— There are a lot of reasons where you would want to “deep copy” objects in your application. For instance, when working with React.js, you might have used the shouldComponentUpdate life-cycle method. In this method, you would determine if the component has the same props and state as it had previously by shallow or deep copying objects.

Read More ⟶

Why You Should Use JavaScript for Game Design

— There are several different coding languages that can be used in the design of online video games. Per Code Digest, some of the most common among them are HTML5, C++, Java, C#, and JavaScript. Each of these languages has been used successfully to produce games, and each one can be used for this purpose even by a relative beginner (so long as he or she is willing to learn during the process).

Read More ⟶

Things to consider before using arrow functions in JavaScript

— Although the Arrow functions in JavaScript are a great way to make your code concise and more readable than the regular functions, there are some important things that you should consider before using arrow functions which can even break your application if you’re not aware of this.

Read More ⟶

Detect device's OS in JavaScript

— There comes a scenario when you might want to check which operating system the device is running. For instance, when you want to set device-specific download links. For windows, .exe file, for macOS, .dmg file and so on.

Read More ⟶

Detecting if device is online or offline using plain JavaScript

— There might be cases where you would like to check if the device on which the website is loading is connected to the internet or not. For instance, this can be used to show the user the message if their device is offline or to disable some functionality of the application if the device is offline.

Read More ⟶

Asynchronous for loops in JavaScript

— There are several ways to iterate over things in JavaScript. Most notable way is to use loops. Loop constructs includes for, forEach, do...while, while, for...in and for...of. All these constructs loops over synchronous iterables such as arrays, objects, strings etc.

Read More ⟶

Type checking props using PropTypes in React

— JavaScript is not a statically typed language. A language is a statically typed if the type of a variable is known at compile-time instead of at run-time. Common examples of statically-typed languages include Java, C, C++, Swift, Kotlin and Scala.

Read More ⟶

Supercharge array operations using Set in JavaScript

— Working with Arrays in JavaScript is sometimes painful as there aren’t a lot of native functions/methods available to carry out common operations on arrays. For instance, an operation as simple as removing an element from an array takes a lot of amount of code. Check this.

Read More ⟶

A look into Getters and Setters in JavaScript

— There are always multiple ways of doing things. Programming is no different. For instance, in JavaScript, what would you do if you want to get the property of an object running some operation before returning it? Take this example.

Read More ⟶

TIL - How to fix embedded scripts in Progressive Web Apps

Progressive Web Apps are great when you need to achieve things like offline capabilities, push notifications, background-sync and to give your website an overall app-like experience. While, the PWAs are great at implementing all of the above things and are the obvious choice, there are certain things which can be broken when you use ServiceWorker(which are the building blocks of any PWA) to make your webaite a PWA.

Read More ⟶

Getting started with Electron

— Have you ever wanted to develop desktop apps while being a true web developer without even caring about the native architecture or the language most of the applications build for different platforms likes of Windows, macOS or Linux? Or you just wanted to get started with building desktop apps? Isn’t it great if you are able to build desktop apps using the technologies you already knows i.e. HTML, JavaScript and CSS? I was in the same urge to dive into world of desktop apps. So, I have been stuck on to GitHub’s Electron lately.

Read More ⟶