JSK Weekly - December 30, 2020

From all of us at JavaScript Kicks, we'd like to wish all our readers a very Happy New Year and everything wonderful for 2021!


General

Return a Default Value with Promises Using catch

Last week I tweeted all of you looking for your best JavaScript Array and Promise tricks, and as always, it didn't disappoint -- I learned quite a bit! Today's JavaScript Promise trick is brought to you by Claudio Semeraro: how to use catch to set a default value instead of a try/ catch: // Instead of wrapping this block in a try/catch...

Authored by: David Walsh

Web Vitals from Google to Measure User Experience

You don't need to be an expert in any area to understand Web Vitals. They are simple things like mobile-friendliness, browsing safety, HTTPS, interactivity, visual stability, loading time, etc. Out of these Web Vitals, Google has identified three main measurements as Core Web Vitals common across all types of websites.

Authored by: Bit

Setting up Axios Interceptors for all HTTP calls in an application

Think about it: at the advent of the Internet you could send and receive email, search by keywords for information and visit a few, extremely basic websites. Today, you can: order a car and have it pick you up at your exact location within minutes, make purchases with a credit card number stored on your phone, search for extremely specific questions via voice and get thousands of useful, relevant answers.

Authored by: Bit

How To Use Data Attributes In JavaScript, CSS + HTML

This article is a short and quick guide to using data attributes in JavaScript- something I wish I knew more about when I was beginning my own JavaScript journey. Data attributes are actually HTML attributes that allow you to create and assign bespoke data points to HTML elements.

Authored by: JavaScript In Plain English

Writable getters

A pattern that has come up a few times in my code is the following: an object has a property which defaults to an expression based on its other properties unless it's explicitly set, in which case it functions like a normal property. Essentially, the expression functions as a default value.

Authored by: Lea Verou


JavaScript

10 JavaScript Hacks Every Web Developer Should Know

If you optimize your JavaScript code with these hacks, it can help you write cleaner code, save resources, and optimize your programming time. According to RedMonk, JavaScript is the most popular programming language. Furthermore, SlashData estimates that around 12.4 million developers use JavaScript, which also includes CoffeeScript and Microsoft'

Authored by: freeCodeCamp.org

CUID package to generate unique identifiers in JavaScript apps

In the last blog post, we have generated sample testing dataset using faker package. We used the array index value for the ID. Array index value as ID will work if the data is static. But if you add/remove data, then it will be tricky to maintain.

Authored by: Paramanantham

JavaScript's Destructuring Assignment

The destructuring assignment in JavaScript is a fast and easy way to delegate data from object and array literals to variables. If you ever find yourself writing line after line of variable assignments, consider using the destructuring assignment to save lines and time. Order is the name of the game when it comes to the destructuring assignment.

Authored by: JavaScript In Plain English

JavaScript: == vs === Operator

Introduction Comparison operators are used in logical statements to determine whether two variables or objects are equal by some already set or custom defined criteria. If the two variables or objects are deduced to be equal the operator returns true, and false if they aren't.

Authored by: StackAbuse

How the Nullish Coalescing Operator Works in JavaScript

ES11 has added a nullish coalescing operator which is denoted by double question marks, like this: ??. In this article, we will explore why it's so useful and how to use it. Let's get started. Background InformationIn JavaScript, there is a short-circuit logical OR operator ||.

Authored by: freeCodeCamp.org


Angular

Using IntersectionObserver And NgSwitch To Defer Template Bindings In Angular 11.0.5

Showing a really long list of data is usually not that great for the user experience (UX); and, it's usually not that great for the performance of the web page. But, sometimes you don't have a choice. And, in those cases, I often try to find ways to squeeze as much performance as possible out of the rendering.

Authored by: Ben Nadel

Create a CMS with Angular + Firebase

So how do we start? We're using firebase - so we need to go over to google's firebase and create an account. Go ahead; I'm waiting. Ok, waiting's done!. Go over to the firebase console. now do the following: Create a project. Name it, agree to the terms. Disable google analytics Great.

Authored by: JavaScript In Plain English


React

Build a Sticky Table Header with React Hooks

You can build table layouts by using the usual tag or achieve the same via css with display: table and semantic elements ( ). Same visual result. The first one, though, will cause React to complain (also in tests) if you place outside its parent. Warning: validateDOMNesting(...): cannot appear as a child of .

Authored by: Miroslav Nikolov ⚛️

Add a Simple Search Function to React App without a Server

To get started, you need to bootstrap a new React application by using Create React App: npx create-react-app react-fusejs-example Once finished, let's start by writing the books data as an array of objects. You will pass this data to the application and render it as a list of cards: Create a new file named books.json and create your list of books.

Authored by: Bit


Aurelia

A workaround for Shadow Dom shared global styles in Aurelia 2 - I Like Kill Nerds

One of my favourite additions to Aurelia 2 is proper support for Shadow DOM and with it, the ability to encapsulate my styles on a per-component basis, it works well most of the time. However, if you're using a CSS library such as Bootstrap or legacy CSS, you will need to add in some global [...]

Authored by: Dwayne Charrington


Vue

What's Coming To VueX?

Vuex is the go-to state management library for Vue applications, and the Vue core team has some big plans to make it better than ever. Here's a preview of where they are looking to take it. Vuex is the solution for state management in Vue applications.

Authored by: Smashing Magazine

How to Create a Confirmation Dialogue in Vue.js

Introduction A confirmation dialogue is a UI pattern where the user will be given a choice to continue with their action or to cancel it. It is commonly used with destructive or irreversible actions, to make sure that the user would indeed want to proceed.

Authored by: StackAbuse

How to Build Laravel 8 Vue JS Like Dislike System - positronX.io

In this Laravel 8 Vue JS Like Dislike System example tutorial, you will learn how to create a like and dislike system in the Laravel Vue JS application; moreover, we will show you how to store the like and dislike values in the database based on the user id.

Authored by: Digamber Singh


Node.js

Convert web pages into PDFs with Puppeteer and NodeJS

As a web developer, you may have wanted to generate a PDF file of a web page to share with your clients, use it in presentations, or add it as a new feature in your web app. No matter your reason, Puppeteer, Google's Node API for headless Chrome and Chromium, makes the task quite simple for you.

Authored by: livecodestream


Libraries and Tools

NPM Libraries for Iframes in React

Using Iframes in React is straight forward. In fact, you don't need any library at all to embed an Iframe. However, there are advanced use cases where we need the support of libraries. So in this...

Authored by: Bit

A Comparison Of Node.js Web Scraping Tools

In this post, we are going to talk about all the tools/libraries offered by Nodejs for web scraping. We will first start with some easy and basic libraries and then move ahead with advanced tools. We will briefly talk about the pros and cons of each tool.

Authored by: JavaScript In Plain English


Functional Programming

Basics of JavaScript Pure Functions

A function that obeys certain conditions will be deemed as a pure function. Consistency between arguments and output. Same arguments would always return the same output value, regardless of any external factors. No side effects. A pure function will always maintain a relationship where its inputs and output are consistent with one another.

Authored by: Bit

Everything About Callback Functions in JavaScript

The callback function is one of those concepts that every JavaScript developer should know. Callbacks are used in arrays, timer functions, promises, event handlers, and much more. In this post, I will explain the concept of a callback function. Also, I'll help you distinguish the 2 types of callbacks: synchronous and asynchronous.

Authored by: Dmitri Pavlutin

How To Write Functions In TypeScript

The other parts of this series are below for your convenience. 🥳 Part 1 of future-proofing your app Part 2 of future-proofing your app We previously talked about prop-types and moving on to an introduction on TypeScript. Still, our TypeScript introduction was very brief and focused on the typed system of primitive data types.

Authored by: JavaScript In Plain English





0 comments