Javascript examples for Array:map
Get multiple character positions in array via map function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {//w w w .j a v a2s . c o m var mystr = 'w.wer,ads,'; var pos = mystr.split(/[,.]/).slice(0,-1).map(function(val, i, a) { a[i] = val.length+(a[i-1]?a[i-1]+1:0); return a[i]; }); console.log(pos); }); </script> </head> <body> </body> </html>