课程: JavaScript: The Tricky Bits

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Pain point: Function signature doesn’t accept arrays

Pain point: Function signature doesn’t accept arrays - JavaScript教程

课程: JavaScript: The Tricky Bits

Pain point: Function signature doesn’t accept arrays

- [Instructor] Every once in a while you might find a function whose method of invocation doesn't work with your needs but, otherwise, it's a match. In this video, we're trying an example of this, where we have an array of data, but the function we want to use only accepts individual parameters. A built-in example of this is the max method on the global math object, which returns the largest number from an argument list, but wouldn't work with an array of numbers like we have here. Let's look at another real example in the browser. I'm just going to click this go button, wait a few seconds. And then I get the results of some mocked up network requests inserted here into the page. Let's take a look at the code now. I have this promise simulator function that returns a promise that will resolve to the value I specify after a delay that I specify in milliseconds. This is much easier than trying to use a web server…

内容