+ 4

Pls this two brackets ( ) and { } are confusing me, plz hw do i know when to use each of them.

Js

23rd Jun 2019, 3:11 PM
SAMMY.
SAMMY. - avatar
2 Antworten
+ 11
The curly brackets {} are mostly used to define the code that belongs to a function: function a(){ everything here is part of the func } And classes and objects. There are other things, but they’re more rarely used. In time, you’ll become familar with the langauge, and will have no trouble deciding for yourself. It just takes time and practice.
23rd Jun 2019, 3:19 PM
Jax
Jax - avatar
+ 2
{} in many C based languages define a code block and scope.
24th Jun 2019, 7:58 AM
Sonic
Sonic - avatar