Variables vs values, primitives, functions, objects, and classes are values

Photo by the author, Spetses island

Sometimes the concept of a value is obvious like when dealing with numbers or strings. It is clear that numbers, strings, booleans are data and can be used as values.

Sometimes it is not so easier to understand. For example objects, functions and classes are values in JavaScript. …

useState, setTimeout, useEffect, useRef, and more

Photo by the author, Hydra island

This article looks at the challenge of reading the current state value inside a callback for setTimeout or setInterval utility functions.

useState

Let’s start by creating a simple Counter component. It displays a counter and a button incrementing its value.

The state in this example is the counter value.

import {…

The book is available in Kindle, paperback, and hardcover formats

Cover photo

The JavaScript: The Fundamentals book is now available in Kindle, paperback, and hardcover formats.

JavaScript is the language of the web and one of the most used programming languages.

It puts together some powerful features like closures, functions as values, objects as dynamic collections of properties, experimental characteristics, the prototype…

Cristian Salcescu

Author of Functional Programming in JavaScript. Enthusiastic about sharing ideas. https://www.amazon.com/gp/product/B08X3TPCQ8

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store