-1

For example:

What does

this.head = this.tail = new Node(value)

do? How does javascript interpret this line?

Is this the same as writing:

this.head = new Node(value);
this.tail = new Node(value);

If so, is there any limitation on when and where this one line approach can be used?

2

1 Answer 1

0

No, it's assigning the same value to both variables. So it's equivalent to

this.tail = new Node(value);
this.head = this.tail;

Your equivalence would create 2 different Node objects, but there's only 1.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.