针对JavaScript里的arguments对象有如下问题

1.是Array类型的吗?它有哪些属性?

 

// Best practices: it is best not to use arguments

function test(){
	console.log( arguments instanceof Array);//return false arguments is not a instance of Array
	console.log([1,2] instanceof Array);// return true
	console.log( arguments.length); // ok
}

test();
console.log({}.length); //undefined

 结论: arguments是一个特别的Object, 它带了一个length属性

相关文章:

  • 2022-12-23
  • 2022-02-04
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-03
  • 2021-09-27
  • 2022-01-08
  • 2021-05-17
  • 2022-12-23
  • 2021-12-23
  • 2021-10-03
相关资源
相似解决方案