Posts about "JavaScript"

JavaScript Playground in Your Browser

— How many times have you wanted to do some quick prototyping in JavaScript or wanted to test out some code but didn’t want to go through the hassle of setting up a project?

A better setTimeout() in JavaScript

— A pretty long ago, I covered how to handle multiple time intervals in JavaScript in this article. And that’s a good way to handle multiple intervals in JavaScript. In line with that, I recently stumbled upon a pretty interesting way to handle setTimeout() in JavaScript in this tweet by Haz.

Using Bright Data's scraping browser to Scrape Web Pages

— There comes a time when you need to scrape a website for data. For instance, you might want to scrape a website to get the list of all the products they have or you might want to scrape a website to get the list of all the blog posts they have. Or you just want to automate the process of scraping a website for data to make your life easier.

Identify unused npm packages in your project

— If you’re working on a large codebase, chances are you might have installed a lot of npm packages in your project. And you might have used some of them just for the sake of trying them out. But, you might have forgotten to remove them from your package.json file.

Convert any value to a boolean in JavaScript

— When you’re working with JavaScript, you often stumble upon a situation where you need to check certain conditions. And often, you would need a boolean value (true or false) or boolean expression to check for the condition.

Human-readable date difference in JavaScript

— In this article, we will learn how to get the human-readable date difference in JavaScript. We will see how to get the difference between two dates in years, months, days, hours, minutes, and seconds.

How to return multiple values from a function in JavaScript

— It wouldn’t sound too obvious but sometimes your function might need to return multiple values. For instance, in one of the applications I’m working on, I have a JavaScript function where I have to calculate two different values and return them.

Console Logging the Right Way

— Haters gonna hate and call you uncultured but when it comes to debugging, doing console.log() is one of best the best ways of all time. Period. Well! sort of!

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.

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).

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.

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.

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.

Drag and drop files using only JavaScript

— You’ve probably seen or have used this feature where you can upload files by dropping the selected files into the specific area. For example, how Gmail handles this while drafting emails.

What's the use of Blob object in JavaScript?

— I was working on polishing my Notepad app this fine quarantine afternoon. One feature that I was planning to add was an ability to download the content of the notes/text as a text file when user click the specified download button.

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.

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.

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.

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.

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.

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.