Function's Parameters Using Destructuring Assignment

Tell us what’s happening:
I passed the lesson but i have a question. I understand that if the passed object’s all properties will not be used, we have to specify which ones are relevant for the function.

But how the function know which object will be used. For example, if you look down my code:

const half = (function() {
  "use strict"; // do not change this line

  // change code below this line
  return function half({max,min}) {
    // use function argument destructuring
    return (max + min) / 2.0;
  // change code above this line

How the function half will know what object will be used here? Is there a under-the-hood search going on to find a object that has max and min properties? Can someone explain it to me?

Thank you.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:

When you write {max, min} as the parameter for the internal half function which gets returned, JavaScript now expects an object to be passed in which does have those same property names in the object.

1 Like