日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

arguments獲取當前所在函數

作者:Wxinin 更新時間: 2022-04-23 編程語言

arguments是存在AO中的類數組對象
可以使用length和index
但是不能使用數組的一些方法,比如forEach、map

function foo(num1, num2, num3) {
  // 類數組對象中(長的像是一個數組, 本質上是一個對象): arguments
  // callee獲取當前arguments所在的函數
  console.log(arguments.callee)//foo(){}
  // arguments.callee()---這樣寫會遞歸
}

如何將arguments轉化成數組類型

1.for循環遍歷arguments
2.

Array.prototype.slice將arguments轉成array
  var newArr2 = Array.prototype.slice.call(arguments)
  console.log(newArr2)

原文鏈接:https://blog.csdn.net/weixin_44283589/article/details/123733560

欄目分類
最近更新