Skip to content

Instantly share code, notes, and snippets.

@finalcut
Created January 29, 2019 13:34
Show Gist options
  • Save finalcut/314a05665d94a1619bfa707c6ba5868c to your computer and use it in GitHub Desktop.
Save finalcut/314a05665d94a1619bfa707c6ba5868c to your computer and use it in GitHub Desktop.
String Interpolation and String Concatenation Examples in javascript
<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