.replace javascript not working -
hi working in java script have string
var data = 'http://baab.bh/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/t/e/test.jpg';
i want replace /image/ 'image/440x600' using function
.replace()
but not working here code
var data ='http://baab.bh/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/t/e/test.jpg'; data.replace('/image/', '/image/440x600/'); console.log(data);
its showing same not replacing /image/ 'image/440x600'.
strings in javascript immutable. cannot modified.
the replace
method returns modified string, doesn't modify original in place.
you need capture return value.
var data = 'http://baab.bh/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/t/e/test.jpg'; data = data.replace('/image/', '/image/440x600/'); console.log(data);
Comments
Post a Comment