Concatenation in JavaScript 101

Tip of the day. JavaScript concatenation and it’s peculiarities

Concatenating strings and integers in JavaScript can be tricky and might return some unexpected results if you aren’t familiar with how the browser handles this type of stuff.

For example, if you concatenate 10+20+'thirty' the end result will be 30thirty but 'thirty'+20+10 will return thirty2010.

See the Pen Concatenation in JavaScript 101 by carltonstith (@carltonstith) on CodePen.

Leave a Reply

Your email address will not be published. Required fields are marked *