JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods

CONCATENATION IN JAVASCRIPT

Concatenation refers to the process of adding strings together. In javascript, strings are added together with the + sign which is referred to as the string operator.

You use this operator to add strings to variables or variables to variables.

Example: Add Strings And variables

var firstName="John";

alert("Hello" + firstName);

HelloJohn is then outputted.

Notice that there is no space between Hello and John. To add a space between these words, add a space after Hello like below (ie move the quotation mark one space right):

alert("Hello " + firstName);

Example: Add Variables And variables

var firstName="John";
var lastName="Smith";

alert(firstName + lastName);

JohnSmith is then outputted. To add a space between John and Smith, do:

alert(firstName + " " + lastName);

Home | Privacy Policy | Terms Of Use | Contact Us