benhowdle89
benhowdle89

Reputation: 37504

Javascript two equals

Trying to deepen my knowledge of JS, can someone tell me what this does/is please?

jQuery = $ = this.jQuery;

What exactly does two equal signs do here?

Upvotes: 0

Views: 105

Answers (3)

Jontas
Jontas

Reputation: 407

It is simply "stacking" the equals sign as you know it ;)

The example you have could be rewritten to

$ = this.jQuery;
jQuery = $;

I.e. both variables "jQuery" and "$" is set to the value to the right. (So it saves space and might be more clear that both vars are set to the same value.

Upvotes: 0

gen_Eric
gen_Eric

Reputation: 227310

That assigns this.jQuery to $, and then assigns $ to jQuery.

This works because when assigning a value, it returns the value it just assigned, so another variable can be set to it.

Upvotes: 3

ControlAltDel
ControlAltDel

Reputation: 35106

assigned this.jQuery to $ and jQuery

why not just try it out?

Upvotes: 0

Related Questions