Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is {...code...} in javascript?

Tags:

javascript

{
var x = 0;
...
}

What are the curly braces supposed to do, it is clearly not a function or a loop, it's just empty curly braces with nothing before.

p.s. if anyone finds a better way to rephrase this question, please do

like image 261
Fahem Moz Avatar asked Jun 06 '26 16:06

Fahem Moz


1 Answers

Those are called block statements, they are simply there to group together statements to be executed together.

Here are some useful links: https://www.w3schools.com/js/js_statements.asp https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/block

like image 84
Camron Avatar answered Jun 09 '26 05:06

Camron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!