var myarray= ["JOAQUIN", "BERNARDINO", "MODOC","ALASKA","MADERA", "ANDERSON"]
myarray.sort();
we are passing two arguments into source one is request
and second is response
,
request
is stands for request object we are making, in our case it is the letter we are typing into textbox.response
is function which will return us auto complete selection options.
now inside $.map
we are checking typed words with array we have named json.
json.toUpperCase().indexOf(request.term.toUpperCase())
this line convert typed word and array to same case and return it.
and matches would be the final result which has list of item that you have asked.
and response(matches);
will send it to autocomplete.