Want to know what these two pieces of code mean? I don't understand

  const restaurants = keyArray;
      const results = queryString ?
        restaurants.filter(this.createFilter(queryString)) : restaurants;
      //  callback 
      cb(results);
    },
    createFilter(queryString) {
      return restaurant =>
        (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
    },
Apr.01,2021

if querystring exists, results is the restaurants after Filter, otherwise it is the value of restaruants , and then put results into the callback cb to execute


.

this is a Miki expression

the above writing is equivalent to:

let results = null;
if(queryString ){
    results = restaurants.filter(this.createFilter(queryString));
}else{
    results = restaurants;
}

cb(results);
Menu