var x = “Hello ”;

var y = 5;

y += x;

// value of y is ‘Hello5’

When combining a string with a number the output will always be a string. In the above example, y is now a string.

Other operators

There are many more operators available to us in JavaScript, which we will come across in subsequent chapters where they are more relevant, but for now, these are the main operators we are going to be working with. Let’s ensure we have a firm grasp of how they all work so far.

Operators are used everywhere in JavaScript. They form the basics of assigning and manipulating variables to our requirements. They afford us full control over how we want to manipulate our data and allow us to perform very powerful operations. They are used in conjunction with the majority of other concepts you will learn in this book, so it’s very important you fully understand how they function and ‘operate’.