-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

cat_codes
  • 152
  • 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
  • 5,087
  • 1
  • 35
  • 35
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
Avanish Kumar
  • 2,208
  • 3
  • 25
  • 33