1.substring(start,end) 不包括end本身;如果start>end,兩者的位置互換;如果start(或end)小於0,則變爲0
var str = "Hello world!";
var res = str.substring(1,4);
var res = str.substring(1,4);
返回的結果是:ell
2.substr(start,end)包括end本身
var str = "Hello world!";
var res = str.substr(1,4)
var res = str.substr(1,4)
res表示ello
3.slice(start,end)包括end本身
var str = "Hello world!";
var res = str.slice(1,5);
var res = str.slice(1,5);
The result of res will be:
ello