The Difference Between Braces Brackets And Parentheses In JavaScript

I'm always confused about the terms braces, brackets, and parentheses. So this is more a note to myself. But I also noticed a lot of confusion regarding these terms on Twitter and various blogs.

{} are braces, curly braces, or curly brackets.

[] are brackets or square brackets.

() are parentheses.

So braces are used in JavaScript for function bodies and object literals for example.

Brackets are used for arrays.

And parentheses are used in function declarations to surround the functions' parameter list. Parentheses are also used for JS expressions.

Posted on CuteMachine in javascript.

Jo's Profile ImageWritten by Jo who lives and works in Frankfurt building digital doodah. Stalk him on Twitter.

TOS • Privacy • Disclaimer