Uday Hiwarale
1 min readJul 14, 2020

--

```

let x = y = z = 5;

```

Isn't the same thing as

```

let x = 5;

let y = 5;

let z = 5;

```

Try the following code

console.log( window.hasOwnProperty('x')); // false

console.log( window.hasOwnProperty('y')); // true

console.log( window.hasOwnProperty('z')); // true

Try this as well

```

const x = y = z = 5;

y = 10;

console.log(y); // 10

```

In JavaScript, assigment expression returns the assigned value. `z = 5` isn't a declaration, it's an expression. But since `z` doesn't exist, in non-strict mode, it is added to the `window`.

--

--

No responses yet