User autocomplete has a new feature compared to Drupal 7: If, in addition to regular user names, you want the function to return the name used to indicate anonymous users ("Anonymous" by default, sometimes changed to "Visitor" or "Guest"), you can set the $include_anonymous parameter to TRUE when calling the function. For example
// Returns a JSON response with names, including the name to indicate anonymous
// users (in-case it matches the search string).
user_autocomplete(TRUE);
// Same thing, but without the "Anonymous" name.
user_autocomplete();
When requesting a URL, you can use the following to include the name to indicate anonymous users: http://example.com/user/autocomplete/anonymous?q=An. See #autocomplete_path now passes the search string as a GET argument instead of appending to the URL for an explanation of the ?q= change.
When using a user autocomplete as part of a FORM, this path can be used as well.
// This works in Drupal 7 and in Drupal 8 and does not include the name to
// indicate anonymous users.
$form['author']['name'] = array(
'#type' => 'textfield',
'#title' => t('Authored by'),
'#autocomplete_path' => 'user/autocomplete',
);
// This includes the name to indicate anonymous users.
$form['author']['name'] = array(
'#type' => 'textfield',
'#title' => t('Authored by'),
'#autocomplete_path' => 'user/autocomplete/anonymous', // <-- Note the different path.
);