# Odd behavior in code prettifier when using destructed assignment

**URL:** <https://talk.observablehq.com/t/odd-behavior-in-code-prettifier-when-using-destructed-assignment/2737>\
**Category:** Feedback\
**Created:** [January 12, 2020, 5:48pm UTC](https://talk.observablehq.com/t/odd-behavior-in-code-prettifier-when-using-destructed-assignment/2737 "2020-01-12T17:48:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [January 12, 2020, 5:48pm UTC](https://talk.observablehq.com/t/odd-behavior-in-code-prettifier-when-using-destructed-assignment/2737/1 "2020-01-12T17:48:06Z")

</div>

While it’s taken a bit of getting used to, I generally really like the code editor in Observable. Here’s one exception that might be a bug. Suppose I type in the following:

```
{
  let a,b,c
  let x=0
  [a,b,c] = [1,2,3]
}

```

After entering this, the auto-prettifier (perhaps you have another term?) reformats this as:

```
{
  let a, b, c;
  let x = ((0)[(a, b, c)] = [1, 2, 3]);
}

```

Which generates an error.

Of course, it’s easy enough to avoid this by terminating the lines with a semi-colon myself but I’ve rather grown to like not worrying about that. 🙂

---

<div class="post-metadata">

**Author:** ![yurivish](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/yurivish/32/198_2.png) [@yurivish](https://talk.observablehq.com/u/yurivish)\
**Post date:** [January 12, 2020, 7:22pm UTC](https://talk.observablehq.com/t/odd-behavior-in-code-prettifier-when-using-destructed-assignment/2737/2 "2020-01-12T19:22:54Z")

</div>

This is one of the few gotchas of writing semicolon-free Javascript — if the next line begins with `[`, it will attach to the previous line.

The formatting is actually helping you here by showing you what your code means.

---

<div class="post-metadata">

**Author:** ![mcmcclur](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mcmcclur/32/2364_2.png) [@mcmcclur](https://talk.observablehq.com/u/mcmcclur)\
**Post date:** [January 12, 2020, 8:17pm UTC](https://talk.observablehq.com/t/odd-behavior-in-code-prettifier-when-using-destructed-assignment/2737/3 "2020-01-12T20:17:46Z")

</div>

> [@yurivish](#):
>
> This is one of the few gotchas of writing semicolon-free Javascript

Ahh, it’s a Javascript thing rather than an Observable thing - thanks!
