0

This question is related to JS and Vue2 framework.
I would like to understand what a specific line of code means, default: () => [],. Why is the empty array set through the arrow function, and not just []?

export default {
  props: {
    items: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
};

Broader context: I am trying to figure out the logic behind a vue autocomplete app.
Here is the full codepen: https://codepen.io/alligatorio/pen/mXRGLg

Thanks!

theMaertin
  • 21
  • 4
  • An [arrow function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions) returning an empty array. Same as `function() { return []; }`. – Tushar Apr 26 '18 at 12:25
  • Thanks Tushar! This is exactly what I was looking for. Guess I need to read a bit more about the arrow functions. I though I understand them. – theMaertin Apr 26 '18 at 12:31

0 Answers0