Logo
    Search

    Hasty Treat - Seven Interesting JavaScript Proposals - Async Do, JSON Modules, Immutable Array Methods, and More!

    enJune 28, 2021

    Podcast Summary

    • Discussing Exciting JavaScript ProposalsThe Syntax team discussed seven potential JavaScript proposals, sponsored by LogRocket and DQ, comparing the excitement to a child's anticipation for new Lego sets or catalogs.

      The Syntax team, consisting of Wes Bos, Scott Tolinski, and special guest Barracuda Boss, discussed seven intriguing JavaScript proposals in their 300 and 65th episode. These proposals are at different stages and may or may not become part of JavaScript. The hosts compared this excitement to a child's anticipation of new Lego sets or catalogs. They were sponsored by two companies, LogRocket and DQ. LogRocket is a tool that allows developers to see video replays of user interactions, network requests, and errors to better understand and fix issues. DQ, on the other hand, offers Axe DevTools Pro, an advanced version of their accessibility testing tool that includes automated and intelligent guided testing to ensure websites are accessible to all users.

    • ECMAScript TC39: Deciding JavaScript's Future FeaturesECMAScript TC39 carefully considers proposals to add beneficial features to JavaScript, ensuring language consistency and quality.

      The ECMAScript TC39 committee is responsible for deciding which features will be added to the JavaScript language. They have a proposals GitHub where you can find proposals at different stages, from stage 0 (pie in the sky ideas) to stage 3 (solidified features). Not all proposals make it to the final stage, and some can even go backwards if they're not ready. One current proposal is for JSON modules in JavaScript, which could bring improvements to how we handle modules in our code. During the discussion, it was also mentioned that there are various implementations of ECMAScript, including JavaScript (used in browsers), SpiderMonkey, JScript, QtScript, and Google Apps Script. Even Cloudflare has its own version of JavaScript. This shows the versatility and widespread use of JavaScript. It's important to note that the ECMAScript committee carefully considers each proposal to ensure that the features added to the language are well thought out and beneficial for developers. This process helps maintain the quality and consistency of JavaScript. So, the next time you're curious about potential new features in JavaScript, check out the ECMAScript TC39 proposals GitHub. Remember, the journey from an idea to a fully integrated feature can be long, but it's all part of the continuous evolution of JavaScript.

    • Import JSON as JavaScript modulesWith the latest JavaScript features, you can import JSON files as if they were JavaScript modules, ensuring data is treated as plain data and preventing the execution of any potential JavaScript code within the imported file for security reasons.

      With the latest developments in JavaScript, you can now import JSON files as if they were JavaScript modules using the "import x from 'file.json' assert { type: 'json' }" syntax. This is made possible by the bundler transforming the JSON file into a JavaScript file during the build process. This approach offers several benefits, including avoiding the need for additional parsing or transpilation, ensuring data is treated as plain data, and preventing the execution of any potential JavaScript code within the imported JSON file for security reasons. It is essential to note that this is a single default import, meaning you cannot import specific properties from the JSON object. Also, this feature is currently not supported in Node.js with ES modules, but experimental flags are available for testing. As the technology evolves, we can expect to see other file types, such as CSS, becoming importable in a similar manner. This new functionality allows developers to work more efficiently with JSON data and opens up new possibilities for structuring and organizing projects. By treating JSON files as modules, you can enjoy the benefits of modular programming, such as better code organization and easier code sharing, while still maintaining the flexibility and ease of use of JSON data.

    • New JavaScript proposals for efficient array and asynchronous handlingImport Assertions let developers specify conditions when importing modules, enhancing type checking. Array Find and Array Find Last add dot findLast and dot findLastIndex methods for efficient end-of-array searches. Async Do introduces await at the top level for easier asynchronous code handling.

      Several new JavaScript proposals aim to make working with arrays and asynchronous code more efficient and convenient. One such proposal is Import Assertions, which was previously part of a larger proposal but has now been separated. This feature will allow developers to specify conditions when importing modules, enhancing type checking and preventing potential errors. Another proposal, Array Find and Array Find Last, adds dot findLast and dot findLastIndex methods to arrays. This is particularly useful when searching for an element from the end of an array, reducing the need to reverse or duplicate arrays. Python users might be familiar with similar functionality, and there's even a proposal for a similar feature in JavaScript. With these methods, developers can start searching from the end of the array without the need for reversing or copying it. The Async Do proposal introduces the concept of a block of asynchronous code where you can await things. Currently, to use await in a block of code, developers must either create an async function or use an async IIFE (Immediately Invoked Function Expression). The Async Do proposal will enable await at the top level, making it easier to use and more flexible in handling asynchronous code.

    • Exploring methods for handling asynchronous code in JavaScriptAsync do allows functional-style asynchronous coding but requires variables to be defined outside the block, while Promise.all with multiple async do statements offers promise resolving sequences. A new proposal called array by copy aims to simplify array methods by returning new arrays instead of modifying original ones.

      During the discussion, the speakers explored various ways to handle asynchronous code in JavaScript. One such method mentioned was the use of async do, which allows for writing asynchronous code in a more functional style, almost like a self-calling function without actually being one. However, this approach comes with the downside of requiring variables to be defined outside of the block if you need to access the values of the asynchronous code later. Another example given was the use of Promise.all with multiple async do statements. This allows for the use of various promise resolving sequences. Additionally, a proposal called array by copy was introduced, which aims to make all array methods return a new array instead of modifying the original one, eliminating the need to keep track of which methods modify the original data and which don't. Overall, these discussions highlight the importance of understanding different ways to handle asynchronous code and the potential benefits of proposals that aim to simplify common programming tasks.

    • Proposed Immutable Array MethodsA proposal suggests adding immutable versions of common array methods like splice, sort, shift, and push. These methods, with suffixes like spliced, sorted, shifted, and pushed, respectively, simplify coding and make arrays more readable for immutable data without the need for copying or spread operators.

      There's a proposal to add immutable versions of common array methods like splice, sort, shift, and push, with suffixes like spliced, sorted, shifted, and pushed, respectively. These proposed methods would simplify coding by making arrays more readable when working with immutable data, without the need for copying arrays or using spread operators. This idea aligns with the ongoing efforts to enhance JavaScript with features like records, tuples, and the temporal proposal for improving date handling. These enhancements aim to make JavaScript more functional and expressive, addressing one of its current weaknesses. The naming convention of these proposed methods follows the pattern of existing array methods, making the code more intuitive and easier to understand. Overall, this proposal could lead to cleaner and more efficient code, especially in projects that prioritize immutability.

    • Destructuring and variable renaming in nested objectsDestructuring and variable renaming can lead to cleaner and more concise code when dealing with complex nested objects. Use destructuring to access both high-level and low-level variables, and consider pattern matching for more complex matching scenarios.

      The discussion revolved around the benefits of using destructuring and variable renaming in JavaScript, specifically when dealing with nested objects. The speaker explained that this technique allows developers to capture both the high-level value of a destructuring and the lower-level destructured variables. For instance, if there is a variable called "person" with nested variables like "names" and "first," one can use curly brackets to destructure the "first" variable while still being able to destructure the entire "person" variable. This can be useful in situations where accessing both the high-level and low-level variables is necessary. The speaker also mentioned the proposal for pattern matching, which is similar to a fancy switch statement in languages like Rust. It allows developers to match a value against multiple patterns and perform different actions based on the match. Overall, these techniques can lead to cleaner and more concise code, especially when dealing with complex data structures. However, the speaker also acknowledged that these features might not be necessary in all cases and that the decision to use them should depend on the specific use case.

    • JavaScript's switch statement gets an upgrade with match object proposalThe match object proposal enhances JavaScript's switch statement by allowing developers to check multiple conditions inside an object using regular expressions and destructuring assignments, making it more powerful and inspired by other programming languages.

      JavaScript is exploring new ways to enhance its switch statement functionality through proposals like the "match object proposal." This feature allows developers to check multiple conditions inside an object using regular expressions and destructuring assignments, making it more powerful than a traditional switch statement. It's inspired by languages like Rust, Python, F#, Scala, Elixir, Erlang, and C++. With this proposal, JavaScript is moving towards more complex conditional statements and further expanding its capabilities. While there are seven proposals currently being considered, some, like the "temporal proposal," are already confirmed for implementation. If you're interested in trying out some of these features before they become officially stable, you can experiment with their polyfills. Overall, these proposals demonstrate JavaScript's continuous evolution and commitment to providing developers with efficient and expressive tools.

    • Using polyfills for older browser compatibilityEnsure seamless web experiences by adding polyfills for modern APIs like Intersection Observer to projects for older browser compatibility.

      The importance of using polyfills to ensure compatibility with older browsers when implementing modern web technologies. The hosts discussed the use of a specific polyfill for the Intersection Observer API and how it can be added to projects to make them work seamlessly across different browsers. They also encouraged listeners to check out the link to the polyfill in the show notes and consider subscribing or leaving a review if they enjoyed the show. Overall, the episode emphasized the importance of considering compatibility and accessibility in web development projects.

    Recent Episodes from Syntax - Tasty Web Development Treats

    790: State of JS 2023 Reactions

    790: State of JS 2023 Reactions

    Scott and Wes dive into the 2023 State of JavaScript survey, breaking down the latest trends and pain points in front-end frameworks, build tools, and JavaScript runtimes. Tune in for their hot takes and insights on what’s shaping the JavaScript landscape this year!

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    789: Do More With AI - LLMs With Big Token Counts

    789: Do More With AI - LLMs With Big Token Counts

    Join Scott and CJ as they dive into the fascinating world of AI, exploring topics from LLM token sizes and context windows to understanding input length. They discuss practical use cases and share insights on how web developers can leverage larger token counts to maximize the potential of AI and LLMs.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    CJ: X Instagram YouTube TwitchTV

    Randy: X Instagram YouTube Threads

    788: Supabase: Open Source Firebase for Fullstack JS Apps

    788: Supabase: Open Source Firebase for Fullstack JS Apps

    Scott and CJ chat with Paul Copplestone, CEO and co-founder of Supabase, about the journey of building an open source alternative to Firebase. Learn about the tech stack, the story behind their excellent documentation, and how Supabase balances business goals with open-source values.

    Show Notes

    • 00:00 Welcome to Syntax!
    • 00:30 Who is Paul Copplestone?
    • 01:17 Why ‘Supa’ and not ‘Super’?
    • 02:26 How did Supabase start?
    • 08:42 Simplicity in design.
    • 10:32 How do you take Supabase one step beyond the competition?
    • 12:35 How do you decide which libraries are officially supported vs community maintained?
      • 15:17 You don’t need a client library!
    • 16:48 Edge functions for server-side functionality.
    • 18:51 The genesis of pgvector.
    • 20:59 The product strategy.
    • 22:25 What’s the story behind Supabase’s awesome docs?
    • 25:26 The tech behind Supabase.
    • 35:46 How do you balance business goals with open source?
    • 42:01 What’s next for Supabase?
    • 44:15 Supabase’s GA + new features.
    • 48:24 Who runs the X account?
    • 50:39 Sick Picks + Shameless Plugs.

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    CJ: X Instagram YouTube TwitchTV

    Randy: X Instagram YouTube Threads

    787: You Should Try Vue.js

    787: You Should Try Vue.js

    Scott and CJ dive deep into the world of Vue.js, exploring what makes this frontend framework unique and why it stands out from React and Svelte. CJ gives a comprehensive tour, covering everything from getting started to advanced features like state management and Vue’s built-in styles.

    Show Notes

    Vue.js: The Documentary.

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    786: What Open Source license should you use?

    786: What Open Source license should you use?

    Scott and CJ dive into the world of open source, breaking down its meaning, benefits, and the various types of licenses you’ll encounter. From permissive licenses like MIT and Apache 2.0 to copy-left licenses such as GNU GPLv3, they’ll help you choose and apply the right license for your project.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    785: What’s Next for NextJS with Tim Neutkens

    785: What’s Next for NextJS with Tim Neutkens

    Scott and Wes dive into the world of Next.js with special guest Tim Neutkens from Vercel. They explore the latest updates, including the React Compiler and React Server Components, discussing their impact on developer workflows and the future of Next.js development.

    Show Notes

    • 00:00 Welcome to Syntax!
    • 00:30 What does the React Compiler do?
    • 05:04 Will React Compiler help with managing Context?
    • 06:39 What happens if you’re not using a React Compiler?
    • 09:30 Will this work on any NextJS version?
    • 12:18 What are React Server Components?
    • 16:28 Shipping all the data inside an encapsulated component.
    • 20:17 Clearing up the frustrations around retrofitting server components.
    • 23:13 Handing migration.
    • 28:30 Is this just a fetch request with props?
    • 36:41 How closely are the NextJS and React teams working?
    • 41:53 Will we ever get Async Client Components?
    • 43:52 Async Local Storage API.
    • 45:31 Turbopack.
    • 57:51 Sick Picks & Shameless Plugs.

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    784: Logging × Blogging × Testing × Freelancing

    784: Logging × Blogging × Testing × Freelancing

    In this Potluck episode, Scott and Wes tackle listener questions on modern blogging, website environmental impact, and using LangChain with LLMs. They also cover CSS hyphens, unit vs. integration testing, and balancing web development with new parenthood.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott: X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    783: How We Built a Netflix Style “Save for Offline” Feature Into Syntax

    783: How We Built a Netflix Style “Save for Offline” Feature Into Syntax

    Scott and Wes dive into the world of browser caching for audio files, exploring the File System API and the Cache API. They discuss size restrictions across different browsers, how tools like Riverside.fm leverage IndexedDB, and walk through code examples for creating, retrieving, and managing cached audio data.

    Show Notes

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott:X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    782: The Developer’s Guide To Fonts with Stephen Nixon

    782: The Developer’s Guide To Fonts with Stephen Nixon

    Scott and CJ are joined by Stephen Nixon of ArrowType to delve into the world of fonts and type for developers. They explore the intricacies of font creation, the utility of variable fonts, and offer tips for making visually appealing typography on the web.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott:X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    781: Potluck - The Value of TypeScript × Vue vs Svelte × Leetcode

    781: Potluck - The Value of TypeScript × Vue vs Svelte × Leetcode

    In this potluck episode of Syntax, Scott and CJ serve up a variety of community questions, from the nuances of beginner vs. advanced TypeScript to the pros and cons of SvelteKit. They also discuss falling out of love with React, shipping private packages via NPM, and the eternal struggle of always starting but never finishing projects.

    Show Notes

    Sick Picks

    Shameless Plugs

    Hit us up on Socials!

    Syntax: X Instagram Tiktok LinkedIn Threads

    Wes: X Instagram Tiktok LinkedIn Threads

    Scott:X Instagram Tiktok LinkedIn Threads

    Randy: X Instagram YouTube Threads

    Related Episodes

    I can has() new CSS Selector?!

    I can has() new CSS Selector?!

    In this Hasty Treat, Scott and Wes talk about new CSS selectors :has, :where, and :is.

    MagicBell - Sponsor

    MagicBell is the the notification inbox for your product. Add a MagicBell to your product for announcements, billing, workflow, and other notifications. The free plan supports up to 100 Monthly Active Users - use the coupon code SYNTAXFM for 10% off the first 12 months.

    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

     // Finds all p tags that have an anchor tag as a child p:has(a) {} // Can find children of parent as well // Finds the button of a paragraph that contains an a tag  p:has(a) button {} // Finds all p tags that don't have an anchor tag as a child p:not(:has(a)) {} // Finds all p tags where a is a direct sibling p:has(> a) {} // would find 

    Hi

    // would not find

    hi

    In the past we would write

     header p:hover, main p:hover, footer p:hover {   color: red;   cursor: pointer; }  

    :where is essentially a short had for making this easier considering the 2nd half of these selectors is the same. Will make your css dryer

     :where(header, main, footer) p:hover {}  

    Also super handy in avoiding css blocks being ignored for unsupported features.

     // Doesn't work div:has(p), div:some_new_selector(p)  // Will still work for :has if has is supported :where(div:has(p), div:some_new_selector(p))  

    Tweet us your tasty treats

    Hasty Treat - Future Tech We’re Excited About

    Hasty Treat - Future Tech We’re Excited About

    In this Hasty Treat, Scott and Wes talk about future tech — some things you may not have heard about yet, and why we’re excited about them!

    Freshbooks - Sponsor

    Get a 30 day free trial of Freshbooks at freshbooks.com/syntax and put SYNTAX in the “How did you hear about us?” section.

    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

    05:20 - Astro

    • What it is:
    • Why we’re excited about it:
      • Server Side JS frameworks, combine Svelte, React, Vue as needed in one component that is an SFC using markdown style meta data.
      • Scoped CSS by default (a la Svelte). Sass out of the box.
      • Collections import for .md files
     // pages/blog.astro --- import PostPreview from '../components/PostPreview.astro';  const blogPosts = import.meta.collections('./post/*.md'); ---  <main>   <h1>Blog Postsh1>   {blogPosts.map((post) => (     <PostPreview post={post} />   )} main>  

    12:06 - ViteKit

    • What it is:
      • Framework-agnostic
      • API routes
      • Pages (frontend, optional hydration)
      • Adapter for Node, static, Vercel, cf worker, etc. Inspired by SvelteKit.

    15:58 - Svelte Kit

    19:07 - Remix.run

    • What it is:
    • Why we’re excited about it:
      • Made by Michael Jackson, Ryan Florence
      • License-based
      • React-based
      • Caching-focused, uses “the platform”
      • Centralized data loading, works without client JS if needed
      • Better nested routing

    Links

    Tweet us your tasty treats!

    Hasty Treat - The TLD Game

    Hasty Treat - The TLD Game

    In this Hasty Treat, Scott and Wes are playing a game! It’s called the TLD game, where Scott and Wes try to stump each other with questions about top level domains.

    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

    1:55 - The rules of the game

    We pick a TLD from a list, and the other person needs to guess:

    1. Is it for a country or business? -5 points
    2. What country, business, or type of business is it for? -5 points
    3. How much per year does it cost to register? You may also say “unregisterable” +/- off by $$
    4. is scott.___ and wes.___ available? -10 for each

    5:40 - .BO

    7:51 - .BZH

    9:50 - .BANANAREPUBLIC

    11:15 - .BABY

    14:04 - .KR

    16:09 - .MOTO

    17:25 - .AW

    19:16 - .IM

    Links

    Tweet us your tasty treats!

    Merge Conflict 11: Lightning Talks Round 1

    Merge Conflict 11: Lightning Talks Round 1
    It is lightning talk week on Merge Conflict as we cover six different development topics in under thirty minutes. Each topic gets just five minutes of back and forth debate before moving on to the next. This week's topics include markdown, asynchronous programming, hardware and software setup, programmer art, and a little bit of science fiction. While Frank and James picked a few of the topics, many from you our listeners who have been tweeting at us about what you want to hear. Get ready for fast paced development fun on this week's Merge Conflict.

    Links & Show Notes

    Subscribe

    Introducing LogRocket’s Galileo

    Introducing LogRocket’s Galileo
    Today, we have a message from LogRocket, the company behind PodRocket. LogRocket CEO, Matthew Arbesfeld, and Senior Engineering Manager, Renzo Lucioni, sit down to talk about LogRocket's new machine learning layer Galileo. Galileo cuts through the noise of traditional monitoring and analytics tools, proactively scanning your applications to surface the most critical issues impacting your users. Links https://logrocket.com/features/galileo (https://logrocket.com/features/galileo) https://lp.logrocket.com/lp/galileo-beta (https://lp.logrocket.com/lp/galileo-beta) What does LogRocket do? LogRocket combines frontend monitoring, product analytics, and session replay to help software teams deliver the ideal product experience. Try LogRocket for free today (https://logrocket.com/signup/?pdr). Special Guest: Renzo Lucioni .