Which operator is used for string concatenation in JavaScript?

Prepare for the Revature Test with our comprehensive study material. Use flashcards and multiple-choice questions, each with hints and explanations. Get exam-ready now!

In JavaScript, the operator used for string concatenation is the plus sign (+). When the + operator is used with strings, it combines them into a single string. For example, if you have two string variables, let firstName = "John"; and let lastName = "Doe";, you can concatenate them using let fullName = firstName + " " + lastName;, which would result in the value "John Doe".

This operator is versatile in JavaScript; it can also be used for numerical addition. However, when at least one operand is a string, JavaScript will automatically convert other operands to strings and perform concatenation instead of arithmetic addition. This makes the + operator crucial for managing and manipulating strings in any application that involves user interaction or output display.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy