javascript substring


<script>

var str = 'abcdefg';

var str_cut = str.substr(2,4); // substr(start,length) does not change the original string, it only returns the new value

alert(str_cut); // returns 'cdef'

alert(str); // returns 'abcdefg', original value is not changed

</script>

Leave a Comment