Created
January 29, 2019 13:34
-
-
Save finalcut/314a05665d94a1619bfa707c6ba5868c to your computer and use it in GitHub Desktop.
String Interpolation and String Concatenation Examples in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
// define a couple strings | |
var myString = 'first part'; | |
var myOtherString = 'last part'; | |
// concatenate the strings with a space in the middle | |
var myLastString = myString + ' ' + myOtherString; | |
console.log(myLastString, 'concatentation'); | |
// interpolation means replace the value in the squilly brackets with | |
// the actual variables value. | |
var myInterpolatedString = `${myString} ${myOtherString}`; | |
// good debugging way to output some information. | |
console.log(myInterpolatedString, 'interpolation'); | |
</script> | |
</head> | |
<body> | |
this is a test page | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment