
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to concatenate the string value length -1 in JavaScript.
For this, use join(). It will concatenate the string value length-1.
Example
Following is the code −
var count = 5; var values = new Array(count + 1).join('John'); console.log(values); var count1 = 5; var values1 = new Array(count1).join('John'); console.log(values1);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo274.js.
Output
This will produce the following output on console −
PS C:\Users\Amit\javascript-code> node demo274.js JohnJohnJohnJohnJohn JohnJohnJohnJohn
- Related Articles
- How to concatenate multiple string variables in JavaScript?
- How to concatenate two strings so that the second string must concatenate at the end of first string in JavaScript?
- Concatenate string to an int value in Java
- How to concatenate two strings so that the second string must concatenate at the end of the first string in JavaScript?
- How to get the length of a string in JavaScript?
- How to concatenate several strings in JavaScript?
- How to get the length of a string in bytes in JavaScript?
- How to convert a boolean value to string value in JavaScript?
- How to get the primitive value of string in Javascript?
- How to split string when the value changes in JavaScript?
- How to concatenate variable in a string in jQuery?
- How to concatenate a string with numbers in Python?
- Java Program to Concatenate String.
- How to concatenate two JavaScript objects with plain JavaScript ?
- How to concatenate string vectors separated with hyphen in R?

Advertisements