logo
episode-header-image
Oct 2020
13m 5s

Hasty Treat - Enums in JS (GraphQL and T...

Wes Bos & Scott Tolinski - Full Stack Javascript Web Developers
About this episode

In this Hasty Treat, Scott and Wes talk about enums in JS — what they are, what they do, and how they work in JavaScript.

LogRocket - Sponsor

LogRocket lets you replay what users do on your site, helping you reproduce bugs and fix issues faster. It’s an exception tracker, a session re-player and a performance monitor. Get 14 days free at logrocket.com/syntax.

Show Notes

03:11 - What are enums?

  • A type restricting variables to one value from a predefined set of constants
  • Direction = UP / DOWN / LEFT / RIGHT
  • Role = ADMIN EDITOR AUTHOR VIEWER
  • Day of the Week

05:12 - In GraphQL

  • enum Role { ADMIN EDITOR AUTHOR VIEWER}
  • Then

07:05 - In TypeScript

  • First, declare the type:
    • enum direction = { UP, DOWN, LEFT, RIGHT }
  • Then when you defined your function, use that type
    • type User { role: Role } or type User { role: [Role] }

08:49 - In JavaScript

Links

Tweet us your tasty treats!

Up next
Yesterday
931: Project Init - How to Make Good Choices When Starting a New Coding Project
Scott and Wes dive into the fundamentals of project initialization and planning, from outlining ideas and choosing the right tools to making smart technology decisions. They also chat about leveraging AI and collaboration to shape better projects before rolling up your sleeves an ... Show More
30m 46s
Aug 20
930: Text Editor Keybindings, WASM Replacing Docker, LLM apathy and hosting mini apps
In this potluck episode of Syntax, Wes and Scott answer your questions about VS Code vs Cursor, navigating promotions and job titles, database fundamentals, avoiding decision paralysis, how AI is shaping frameworks, and more! Show Notes 00:00 Welcome to Syntax! 00:56 Brought to y ... Show More
55m 37s
Aug 18
929: Cloudflare Blocks AI Crawlers × Debugging Local Data × Raising Kids with Healthy Digital Habits and More
Scott and Wes tackle listener questions on everything from local-first databases and AI-built CRMs to protecting APIs and raising kids with healthy digital habits. They also weigh in on Cloudflare’s AI crawler ban, portfolio critiques, and more hot takes from the dev world. Show ... Show More
53m 58s
Recommended Episodes
Jun 2022
ESLint and TypeScript
Josh Goldberg joins Nick, Chris & a very nasally-sounding KBall for a fun conversation around TypeScript ESLint. They discuss why we need ESLint when we have TypeScript, some useful rules in typescript-eslint, how it works, and a few hot takes along the way! Discuss on Changelog ... Show More
1h 3m
Apr 2022
Postgres.js (JS Party #221)
Rasmus Porsager created Postgres.js –the fastest full-featured PostgreSQL client for Node.js and Deno. Today he joins Jerod for a deep-dive on Postgres, why he created this open source library, and how you can use it to build pg-backed JavaScript applications. Discuss on Changelo ... Show More
50m 6s
May 2023
The ORMazing show
Nick & KBall sit down with the brilliant Stephen Haberman to discuss all things ORMs! 💻🔍 From the advantages and disadvantages of ORMs in general, to delving into the intricacies of his innovative project Joist, which brings a fresh, idiomatic, ActiveRecord-esque approach to Ty ... Show More
1h 12m
Apr 2022
Postgres.js
Rasmus Porsager created Postgres.js –the fastest full-featured PostgreSQL client for Node.js and Deno. Today he joins Jerod for a deep-dive on Postgres, why he created this open source library, and how you can use it to build pg-backed JavaScript applications. Discuss on Changelo ... Show More
50m 6s
Sep 2023
Modernizing packages to ESM
Mark Erikson (web dev professor/historian, OSS Maintainer & engineer at Replay) joins us to talk about the shift from CommonJS to ESM. We discuss the history of module patterns in JS and the grueling effort to push the world’s biggest developer ecosystem forward. Get ready to go ... Show More
1h 5m
Jun 2022
Ahoy hoy, JSNation & React Summit!
Nick went to Amsterdam for JSNation & React Summit 2022 and he joins Jerod to report on all the goodness! He also sits down with two special guests involved with the confs to talk Jest Preview and GraphQL Cache Discuss on Changelog News Changelog++ members save 4 minutes on this ... Show More
1h 11m
Feb 2024
Stately with Laura Kalbag
Stately is a web-based drag and drop editor for collaboratively developing code, diagrams, and documentation. Laura Kalbag is the Developer Advocate at Stately and she joins the show today to talk about Stately, state machines, building good documentation, and more. Josh Goldberg ... Show More
1h 6m
Mar 2024
Netlify and Edge Computing with Erica Pisani
Netlify is a popular hosting platform that provides build, deploy, and serverless backend services for web apps. The platform enables deployment directly from source files stored in a version control system like GitHub. Erica Pisani is a Senior Software Engineer at Netlify. She j ... Show More
42m 16s