When calling a constructor with new, it's not possible to directly use an array and apply (apply does a [[Call]] and not a [[Construct]]). However, an array can be easily used with new thanks to spread syntax.
var dateFields = [1970, 0, 1]; // 1 Jan 1970
var d = new Date(...dateFields);
So why we can't use apply for constructor? Is there any difference between call and construct?
from What is the difference between [[call]] and [[construct]]?
No comments:
Post a Comment