Javascript a=b=c statements

How does this work??

a = b can be seen as both a statement and an expression.

The result of the expression is b.

In other words,

a = b = c;

which can be written as

a = (b = c);

is equivalent to

b = c;
a = b;

Thus your code is equivalent to:

this.slug = this.sliceHashFromHref(href);
document.location.hash = this.slug;

Leave a Comment