Array.prototype.map
is a great tool for this kind of things:
arr.map(function(el) {
return 'images/' + el;
})
In ES2015+:
arr.map(el => 'images/' + el)
More Related Contents:
- How to set same value for all the text fields with same name attribute using Javascript?
- How to check the value of input [closed]
- What is component in reactjs?
- How to rewrite this code using recursion? [closed]
- What’s the best way to validate an email address in JavaScript?
- How can I add a key/value pair to a JavaScript object?
- How to invoke a JSF managed bean on a HTML DOM event using native JavaScript?
- How can I detect pressing Enter on the keyboard using jQuery?
- Detecting when user scrolls to bottom of div with jQuery
- Comparing Arrays of Objects in JavaScript
- Can Javascript read the source of any web page?
- Chrome counts characters wrong in textarea with maxlength attribute
- How to trigger click on page load?
- Can we refer to JavaScript variables across webpages in a browser session?
- How to add Drop-Down list () programmatically?
- How can I get the title of a webpage given the url (an external url) using JQuery/JS
- Why most of the time should I use const instead of let in JavaScript?
- where is create-react-app webpack config and files?
- Ways to save Backbone.js model data?
- Shallow-clone a Map or Set
- Prevent IE11 caching GET call in Angular 2
- How do I access properties of a javascript object if I don’t know the names?
- javascript variable scope in the IF statement
- Sorting Array with JavaScript reduce function
- onEnter not called in React-Router
- javascript onbeforeunload not showing custom message
- Find selected item in Datalist in HTML
- HTML/Javascript Button Click Counter
- Programmatically accessing function scope using Chrome DevTools console
- Making a live clock in javascript