# Writing Javascript

**URL:** <https://forum.freecodecamp.org/t/writing-javascript/79801>\
**Category:** General\
**Created:** [January 23, 2017, 8:57pm UTC](https://forum.freecodecamp.org/t/writing-javascript/79801 "2017-01-23T20:57:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lou1130](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@lou1130](https://forum.freecodecamp.org/u/lou1130)\
**Post date:** [January 23, 2017, 8:57pm UTC](https://forum.freecodecamp.org/t/writing-javascript/79801/1 "2017-01-23T20:57:04Z")

</div>

When writing javascript is there a format ? I guess the question is what is best practice for writing javascript. Should the `const` come first followed by `function` then `conditions` or `loops` ?

---

<div class="post-metadata">

**Author:** ![vdineva](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/vdineva/32/162986_2.png) [@vdineva](https://forum.freecodecamp.org/u/vdineva)\
**Post date:** [January 23, 2017, 9:20pm UTC](https://forum.freecodecamp.org/t/writing-javascript/79801/2 "2017-01-23T21:20:11Z")

</div>

Check this out, I hope it answers some of your questions:

> **[JavaScript Clean Coding Best Practices | @RisingStack](https://blog.risingstack.com/javascript-clean-coding-best-practices-node-js-at-scale/)**
>
> This post covers general clean coding guidelines for naming and using variables & functions, as well as some JavaScript specific clean coding best practices

---

<div class="post-metadata">

**Author:** ![PortableStick](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/portablestick/32/65591_2.png) [@PortableStick](https://forum.freecodecamp.org/u/PortableStick)\
**Post date:** [January 23, 2017, 9:22pm UTC](https://forum.freecodecamp.org/t/writing-javascript/79801/3 "2017-01-23T21:22:44Z")

</div>

Ask 20 programmers this question and you’ll get 25 1/2 answers 😄

Organizational skills will come with time. Generally, I keep variable declarations - including function expressions - at the top of their scope (usually at the top of their function) and function definitions below that. For the most part, their position is more about human readability than anything to do with how the code is executed. Loops, on the other hand, need to be wherever they’ll be used.

As you learn more, you’ll find many more things that will vary with style. Semicolons, or no? Parentheses inside or outside of an IIFE? Tabs or spaces? There are actually plugins for desktop editors that will check the style for you, so you can get an error or warning when you’re deviating from your workplace’s style.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:11pm UTC](https://forum.freecodecamp.org/t/writing-javascript/79801/4 "2021-01-16T17:11:03Z")

</div>

Closed on January 16, 2021, 5:11pm UTC


