using IIFEs just to give these javascript files some sense of structure

@aescling const has block scope and can’t be reassigned, so you have to use an IIFE plus a return if you want the value of a const to be determined within a block but available outside of it. this is in fact one of the the only reasonable applications of IIFEs in modern javascript code, but it’s very useful.

// Doesn’t work:—
{
const foo = "🎱"
const bar = `${ foo }ball`
}
console.log(bar)

// Works:—
const bar = (() => {
const foo = "🎱"
return `${ foo }ball`
})()
console.log(bar)

@Lady any idea if the do block thing is advancing in the standardization process or no?

Follow

@aescling Stage 1; last presented June 2020; seems like there was general support for it but some spec work to be done before it could advance to Stage 2; looks like they’re still hashing some things out, in particular in relation to break/return

· · Web · 1 · 0 · 0

@aescling so no, it isn’t advancing, but it isn’t abandoned

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.