我這樣寫我的函數: truncate('Hello world!, 5);但我想這樣寫我的函數: 'Hello world!'.truncate(5);function truncate(str, num) { if (str.length <= num) { return str}return str.slice(0, num) + '...'}console.log(truncate('Hello world!', 5))
如何將函數的參數放在開頭
開滿天機
2021-10-14 15:56:29