How To Convert An Object To An Array In Vanilla Javascript

How To Convert An Object To An Array In Vanilla Javascript

I do quite a lot of work with Firebase and when you are working with authentication claims, they will be returned as an object containing your simple values (usually booleans). Thankfully, since ES2015 landed, each Javascript release has introduced a new and easier way to work with objects and convert them into arrays. You don’t […]

I do quite a lot of work with Firebase and when you are working with authentication claims, they will be returned as an object containing your simple values (usually booleans).

Thankfully, since ES2015 landed, each Javascript release has introduced a new and easier way to work with objects and convert them into arrays. You don’t need any libraries like Lodash, this is all native and well-supported vanilla Javascript.

To convert an object of properties and values, you can use Object.entries however, it will return an array of arrays, which isn’t terrible but might confuse Javascript novices as to how you would even work with these.

JavaScript

const claims = {
    admin: true,
    superAdmin: false
};
​
const claimsArray = Object.entries(claims);

Now, if you were to console.log claims array from above, this is what you would get.

JavaScript

javascript vanilla javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How To Calculate A JavaScript Date X Months Ago With Vanilla JavaScript

Working with dates in 2020 are still a mess. Presumably, they’ll also be a mess to work within 2021, 2022 and for a good while after that. Many (myself included) reach for a date library to fill the gaps. For years Moment.js reigned supreme and for good reason, it can do everything with dates, including working with different time zones. Unfortunately, Moment can also result in bundle bloat.

The essential JavaScript concepts that you should understand

The essential JavaScript concepts that you should understand - For successful developing and to pass a work interview

Smooth Scroll | Momentum Scrolling | Vanilla Javascript

In this video, I have created smooth scrolling aka momentum scrolling using javascript,html and css3. It's really a quick and simple way for building smooth scroll in html/css and javascript. It can be useful for displaying any kind of information in different sections or may be in a landing page using smooth scroll on a webpage. Smooth Scroll | Momentum Scrolling | Vanilla Javascript

When to Use Vue.js vs Vanilla JavaScript

In this video we will learn When to use Vue.js vs Vanilla JavaScript

Tutorial — Tic-Tac-Toe Game with Vanilla JavaScript

This is a tutorial on how to build a very basic tic-tac-toe game with vanilla javascript, html, css.