Language/JavaScript

Array.prototype.map.call()

idleday 2025. 1. 13. 12:12

4 methods are identical

  • Array.prototype.map.call(dataSet, function)
  • [].map.call(dataSet, function)
  • dataSet.map(function)
  • dataSet.map.call(dataSet, function) 

아래 두 개는 dataSet으로 정확히 array를 넣어줘야함

 

 

 

[].map.call() VS Array.prototype.map.call()?

Why would one be preferred over the other? [].map.call(...) Array.prototype.map.call(...) Doing a quick test in jsPerf shows the Array.prototype way is more performant, although I read somewhere...

stackoverflow.com