Image for post
Image for post
Photo by Glenn Carstens-Peters on Unsplash

Since 2015, JavaScript has improved immensely.

It’s much more pleasant to use it now than ever.

In this article, we’ll look at issues with maps, sets, and typed arrays.

Why do Maps and Sets have the size Property?

Maps and sets have the size property instead of length because they aren’t sequential data structures, unlike arrays.

length is meant for sequential data structures like arrays.

Configure How Maps and Sets Compare Keys and Values

There’s no way to configure how maps and sets compare their keys and values.

This feature is hard to implement efficiently and properly.

Specify a Default Value when Getting Something out of a Map

There’s no short to specify a default value when we get something out of a map.

Maps don’t let us set the default value directly. …

Image for post
Image for post
Photo by Franck V. on Unsplash

Vue 3 is in beta and it’s subject to change.

Vue 3 is the up and coming version of Vue front end framework.

It builds on the popularity and ease of use of Vue 2.

In this article, we’ll look at how to use props with Vue 3.

One-Way Data Flow

Props have a one way downward binding between the parent and child component.

When the parent property updates, then the updates are passed into the child via props.

This prevents child components from accidentally mutating the parent’s state.

And this makes our app easier to understand.

We should never mutate props.

If we need to change their value, then we should assign them to a new property first. …

Image for post
Image for post
Photo by Carl Flor on Unsplash

React is a popular library for creating web apps and mobile apps.

In this article, we’ll look at some tips for writing better React apps.

React.useState does not Reload State from Props

React.useState doesn’t reload state from props.

It can only set the initial state.

If we need to update the state as props change, then we need to use the useEffect hook.

For instance, we can write:

function Avatar({ username }) {
const [name, setName] = React.useState(username);
React.useEffect(() => {
}, [username])
return <img src={`${name}.png`}/>

We get the username prop .

And we set it as the initial value of the name state with useState . …


John Au-Yeung

Web developer. Subscribe to my email list now at http://jauyeung.net/subscribe/. Email me at hohanga@gmail.com

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