Dot notation vs Bracket notation

Samantha Ming
DailyJS
Published in
4 min readJun 17, 2019

--

CodeTidbit by SamanthaMing.com

Both notations can access object properties. But the question is often which one should I use 🤔. Wonder no more, just follow Airbnb’s style guide. Always use Dot. And when you want to access object property with a variable, use Bracket 👍

// Dot notation vs Bracket notationconst variable = 'cookie';const snack = {
cookie: '🍪'
};

--

--

Samantha Ming
DailyJS

Frontend Developer sharing weekly JS, HTML, CSS code tidbits🔥 Discover them all on samanthaming.com 💛