Intercept the fg on the right side of abcdefg
Method one
<script>
string="abcdefg"
alert(string.substring(string.length-2,string.length))
</script>
Method 2
<script>
alert("abcdefg".match(/.*(.{2})/)[1])
</script>
<script>
alert("abcdefg".match(/.{2}$/))
</script>
Method 3
<script>
alert("abcdefg".slice(-2)) //Recommend this, it is relatively simple, -2 means to take the two characters on the right
</script>