WeSearch

Blockless Scope: JavaScript Shenanigans

·4 min read · 0 reactions · 0 comments · 19 views
#javascript#webdev#programming
Blockless Scope: JavaScript Shenanigans
TL;DR · WeSearch summary

The article discusses the concept of blockless scope in JavaScript, particularly focusing on the differences between var and let. It explains how var is function-scoped while let is block-scoped, even in scenarios without explicit blocks. The author provides examples to illustrate these concepts and their implications in coding practices.

Key facts
Original article
DEV.to (Top)
Read full at DEV.to (Top) →
Opening excerpt (first ~120 words) tap to expand

try { if(localStorage) { let currentUser = localStorage.getItem('current_user'); if (currentUser) { currentUser = JSON.parse(currentUser); if (currentUser.id === 860505) { document.getElementById('article-show-container').classList.add('current-user-is-article-author'); } } } } catch (e) { console.error(e); } Samuel Rouse Posted on May 27 Blockless Scope: JavaScript Shenanigans #webdev #javascript #beginners #programming Shenanigans (3 Part Series) 1 🧐 JavaScript Shenanigans: Time Travel with Destructuring 2 Chaos Proxy: JavaScript Shenanigans 3 Blockless Scope: JavaScript Shenanigans As a JavaScript developer, you've likely been told that let and const are block scoped. But, how does that work when there is no block? Classic Example: var vs.

Excerpt limited to ~120 words for fair-use compliance. The full article is at DEV.to (Top).

Anonymous · no account needed
Share 𝕏 Facebook Reddit LinkedIn Threads WhatsApp Bluesky Mastodon Email

Discussion

0 comments

More from DEV.to (Top)