Last active
September 27, 2015 08:27
-
-
Save flipflop/1240520 to your computer and use it in GitHub Desktop.
String Concatenation in JavaScript
This file contains 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
// old concatenation (creates a new variable in memory for each +) | |
var stuckTogetherOld = "value1" + "value2" + "value3"; | |
// Better: | |
// Front End Performance Tip for string concatenation or JS Templates | |
var stuckTogether = ["value1", "value2", "value3"].join(""); | |
// Quicker to execute | |
var tmpl = ''.concat( | |
'<div>', | |
'<span>foo<span>', | |
'</div>' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment