Emit function in Vue.js

Vue components have a $emit() function that allows you to pass custom events up the component tree.(1)

generally, emit function notifies parent component that something has changed in child component.

I will deep into emit function with an example.

I have a child component as <SearchJokes /> . It is a component that filters the jokes as whatever typed as input. The jokes are just a big array that has all the common jokes in there.

My parent component is index.vue.js.