#how-to

Found 44 articles tagged with #how-to

How to extend interfaces in TypeScript

When one interface extends another, it inherits all the members (properties and methods) from the parent interface and can also add its own members or override the ones inherited.

May 17, 2023#typescript#how-to

How to sort an array by date value in JavaScript

This tutorial provides a concise explanation of how to sort an array by date value in JavaScript using the sort() method and a custom comparison function.

May 15, 2023#javascript#how-to

How to turn an image into a data URI string in Node.js

You can use data URI strings to include small files or binary data in your web pages without having to make separate HTTP requests for them.

May 13, 2023#node#how-to

How to check if file exists in Node.js

Whether you need to verify if a file exists before performing an operation or simply want to handle different scenarios based on file availability.

May 12, 2023#node#how-to

How to wait for multiple promises in JavaScript

It is common to encounter situations where you need to make multiple asynchronous requests to an API or a database and wait for all of them to complete before taking further actions.

May 10, 2023#javascript#how-to

How to sort by object property in JavaScript

When it comes to sorting an array of objects, the sort() function can be used with a custom compareFunction to sort the objects based on a particular property.

May 09, 2023#javascript#how-to

TypeScript optional, nullable, and default parameters

These features enable you to write more flexible and robust code by allowing for the possibility of "undefined" or "null" values, and by providing default values when no value is passed in.

May 09, 2023#typescript#how-to

How to check if string contains substring in JavaScript

You can use either .includes(), .indexOf(), .search(), .match(), regular expressions, or 3rd-party libraries to check if string contains substring.

May 02, 2023#javascript#how-to

How to use fetch() with CORS and credentials

You need to specify some options in the second parameter of the method. The most important ones are: "mode", "credentials", "headers".

How to create enums in JavaScript

In JavaScript, there is no built-in support for enums like in other programming languages, but there are a few ways to emulate enums.

Apr 29, 2023#javascript#how-to