How to use 'javascript concatenate string and variable' in JavaScript

Every line of 'javascript concatenate string and variable' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
83concatenateString(binaryExpression, string = '') {
84 if (binaryExpression.operatorToken.kind !== ts.SyntaxKind.PlusToken) {
85 return
86 }
87
88 if (binaryExpression.left.kind === ts.SyntaxKind.BinaryExpression) {
89 string += this.concatenateString(binaryExpression.left, string)
90 }
91 else if (binaryExpression.left.kind === ts.SyntaxKind.StringLiteral) {
92 string += binaryExpression.left.text
93 }
94 else {
95 return
96 }
97
98 if (binaryExpression.right.kind === ts.SyntaxKind.BinaryExpression) {
99 string += this.concatenateString(binaryExpression.right, string)
100 }
101 else if (binaryExpression.right.kind === ts.SyntaxKind.StringLiteral) {
102 string += binaryExpression.right.text
103 }
104 else {
105 return
106 }
107
108 return string
109}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

135function JS_STRING_CONCAT(a, b) {
136 return a + b;
137}

Related snippets