How to convert all Array values to LowerCase in JavaScript or with lodash
You can also now achieve this very simply by using an arrow function and the map() method of the Array:
var words = ['Foo','Bar','Fizz','Buzz'].map(v => v.toLowerCase());
console.log(words);
Note that map()
will only work in browsers which support ES2015. In other words, anything except IE8 and lower.
If you want to use lodash library you can do the following:
var words = ['Foo','Bar','Fizz','Buzz']
var result = map(words, (v) => lowerCase(v))
console.log(result);
That’s it for now.
If you liked this article, then please subscribe to my YouTube Channel for video tutorials.