I have an array containing 10 elements, each element contains a " " .
" "
How to create a string of spaces, for example:
""
in javascript or jQuery from this array?
thanks
You would use Array.join() , for example:
Array.join()
var myArray = [" "," "," "," "," "," "," "," "," "," "]; var myString = myArray.join(''); //mySting is a string of 10 spaces
You need to pass '' to .join() , because the default collector is a comma.
''
.join()
Easy, try it yourself in the address field:
javascript:alert('"'+new Array(42).join(' ')+'"')
By the way, "in jquery" should be "using jquery"
You can use the connection for this. Example:
var x = ['a', 'b', 'c', 'd']; var y = x.join('');
Source: https://habr.com/ru/post/1316646/More articles:awk + single-line awk syntax for printing only after the second field, if the match is "true" - awkAndroid: screen rotation inside Activity does not switch portrait / landscape - androidAre there any ASP.NET template technologies that can be used both on the client side and on the server side? - templatesRestarting iPhone application after [UIApplication sharedApplication] openURL - iphoneC / C ++ daemon record (Linux) - c ++https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1316647/how-to-pass-unit-of-work-container-into-constructor-of-repository-using-dependency-injection&usg=ALkJrhiJbmEXCQu_4RjiRqLSv9sK4Xc85Qdjango flatpages do not work - djangohttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1316649/memory-leak-in-aspnet-application-w3wp-and-gen-2-heap-continues-to-grow-until-apppool-recycles&usg=ALkJrhiQIEcQ0xKwdhQFNyKWhGDYpcvxUAThe best reference source for Java interaction with jRuby - javaParsing custom feed elements with FeedZirra - ruby | fooobar.comAll Articles