Time complexity of Array.from
问题 What would be the time complexity of Array.from() . For example: const set = new Set(); set.add('car'); set.add('cat'); set.add('dog'); console.log(Array.from(set)); // time complexity of making this convertion from Set to Array 回答1: It's O(n) . When used on an iterable (like a Set ), Array.from iterates over the iterable and puts every item returned into the new array, so there's an operation for every item returned by the iterable. 回答2: It is always going to be O(n) as the number of