You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
358 B
11 lines
358 B
// 函数的参数可传可不传,后面添加 ?
|
|
// 可选参数只能出现在参数列表的最后,就是说可选参数后面不能再出现必选参数
|
|
|
|
// start 和 end 参数可传可不传
|
|
function mySlice(start?: number, end?: number): void {
|
|
console.log('起始索引:', start, '结束索引:', end)
|
|
}
|
|
|
|
mySlice()
|
|
mySlice(1)
|
|
mySlice(1, 3)
|