Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Aral Balkan
Aral Balkan
@aral@mastodon.ar.al  ·  activity timestamp 2 weeks ago

Little JavaScript tip:

You know you can comment out code to quickly disable it:

```js
/*
console.log(‘I won’t run’)
*/
```

But did you know you can also use a labelled block with a break statement to do the same thing in a more flexible manner?

```js
disable: {
break disable
console.log(‘I wont’t run’)
}
```

Then, you can quickly the move the `break disable` to different lines to execute different bits of code within the block.

(Of course, ideally, you should use your JavaScript debugger and break points but, hey…)

Enjoy! 💕

#JavaScript #tip #dev #debugging

  • Copy link
  • Flag this post
  • Block
Simon D.
Simon D.
@siltaer@piaille.fr replied  ·  activity timestamp 2 weeks ago

@aral Don't get puzzled like me by the markdown syntax…

It's just :

disable: {
break disable
console.log(‘I wont’t run’)
}

***

I'm earning my life heavily doing JavaScript since a decade, and it was the 1st programming language I learnt 25 years ago, but I never seen, nor used, nor really know this before

(I just move console.log from place to place…)

#JavaScript

  • Copy link
  • Flag this comment
  • Block
Baraa family
Baraa family
@baraa1998@mastodon.social replied  ·  activity timestamp 2 weeks ago

@aral hello Mr Aral please share my last post🙏🙏

  • Copy link
  • Flag this comment
  • Block
Free Gardenia
Free Gardenia
@Gardenia@piaille.fr replied  ·  activity timestamp 2 weeks ago

@aral Salut Aral. En ce moment je ne comprends rien à ce que tu racontes, j'avoue.

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.40 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct