#how-to

Found 44 articles tagged with #how-to

How to wait n seconds in JavaScript

The most common way is to use setTimeout method, which allows you to execute a function or a code block after a specified amount of time in milliseconds.

Aug 03, 2023#javascript#how-to

7 ways to scroll an element in JavaScript

There are many ways to scroll the window or an element to a specific position, by a specific amount, or into the visible area, with different options for alignment and smoothness.

How to stop useEffect run twice since React 18

One of StrictMode checks is to intentionally render your components twice in development mode, to detect any unintended side effects or state mutations, but not in production mode.

Jul 25, 2023#react#how-to

How to get current folder in Node.js

Current folder refers to 2 possible locations: current folder in project using __dirname variable, and current working directory using process.cwd or dot-slash notation.

Jul 20, 2023#node#how-to

How to return string from a function in C

It's impossible to use strings without using pointers in C, often recommended to provide clear docs to communicate whether the caller is responsible for freeing the memory.

Jul 05, 2023#c#cpp#how-to

Deep dive into try-catch error types in TypeScript

You can throw any value, but the only type annotations that are allowed on catch clause variables are `any` or `unknown`, which are the most general types in TypeScript.

Jul 04, 2023#typescript#how-to

How to promisify a function in Node.js

Promisifying is converting a callback-based function into a function that returns a promise, which allows you to use promise chaining or convenient async/await syntax.

Jun 30, 2023#node#how-to

How to get for...of loop index in JavaScript

The for...of loop does not provide the index of the element by default. If you need the index, you can use Array.prototype.entries() or Array.prototype.indexOf().

Jun 29, 2023#javascript#how-to

How to uninstall Xcode and clear its junk completely

Uninstalling Xcode can be tricky due to its junk data. You must locate multiple files, folders, and dependencies that need to be removed to free up space.

Jun 27, 2023#xcode#how-to#ios

How to design a URL shortening service like Bitly

An URL shortening service is a web app that converts a long URL into a short URL. It does this by using a redirect, which is a link that connects the short URL to the long one.