Skip to content

Instantly share code, notes, and snippets.

@cheng470
Created October 10, 2014 12:53
Show Gist options
  • Save cheng470/05eb96a112f943097293 to your computer and use it in GitHub Desktop.
Save cheng470/05eb96a112f943097293 to your computer and use it in GitHub Desktop.
clearArray1 = (arr) ->
arr.splice 0, arr.length # 返回被删除的部分,即原数组
clearArray2 = (arr) ->
arr.splice 0, arr.length
arr # 返回被清空的数组
clearArray3 = (arr) ->
arr.splice 0, arr.length
return # 单独使用return,什么都不返回
arr = ["a", "b", "c"]
console.log clearArray1(arr)
console.log clearArray2(arr)
console.log clearArray3(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment