-4

More specifically, why do I need the + sign on both sides of my variable ? Here there is an example , for more context of what I'm asking: link

intro__codes
  • 172
  • 9

2 Answers2

0

You're effectively defining a CSS selector, see docs.

The selector must be a string, $n here is a variable and the + signs concatenate (join together) the string and the variable.

robstarbuck
  • 6,893
  • 2
  • 41
  • 40
0

+ operator use for concat two string in javascript and jQuery

Example:

var a = 'Avanish';
var b = a+' Kumar';
console.log('Value of a---->'+a);
console.log('Value of b---->'+b);

output is

 Value of a---->Avanish
 Value of b---->Avanish Kumar

http://www.w3schools.com/js/js_operators.asp

How to force addition instead of concatenation in javascript

Community
  • 1
  • 1
A.K.
  • 2,284
  • 3
  • 26
  • 35