Use the concatenation operator +
, and the fact that numeric types will convert automatically into strings:
var a = 1;
var b = "bob";
var c = b + a;
More Related Contents:
- How do JavaScript closures work?
- html form that passes information to a variable in javascript [closed]
- What is the scope of variables in JavaScript?
- JavaScript OR (||) variable assignment explanation
- JavaScript check if variable exists (is defined/initialized)
- How can I determine if a variable is ‘undefined’ or ‘null’?
- Why is the value of my input always empty if I store it in a variable?
- JavaScript check if variable exists (is defined/initialized)
- var name produces strange result in Javascript [duplicate]
- What does ${} (dollar sign and curly braces) mean in a string in JavaScript?
- Set Webkit Keyframes Values Using Javascript Variable
- Javascript “Variable Variables”: how to assign variable based on another variable?
- JavaScript loop variable scope
- Dynamic variables names in javascript
- What does variable declaration with multiple comma separated values mean (e.g. var a = b,c,d;)
- javascript pass object as reference
- Global variables in Google Script (spreadsheet)
- Variables set during $.getJSON function only accessible within function
- Dynamic object property names?
- how to access object property using variable [duplicate]
- Append to string variable [closed]
- Global variables in Javascript and ESLint
- How can I make a program wait for a variable change in javascript?
- Variable re-assignment of object reference leaves other object unaltered (no “transitive” assignment)
- What does [] mean in JavaScript?
- How to access a JavaScript variable from code behind in asp.net
- Why does accessing a non-existent object property result in `undefined` instead of throwing a `ReferenceError`?
- Setting onclick to use current value of variable in loop [duplicate]
- Can a JavaScript variable be used in plain HTML?
- Javascript: Get access to local variable or variable in closure by its name [duplicate]