How to add a reset button in a form in Drupal 8

Reset button in form can be added directly in buildForm method of Form class or using a form alter.

$form['action']['reset'] = [

     '#type' => 'button',
      '#value' => 'Clear',
      '#attributes' => ['onclick' => 'this.form.reset(); return true;'],

];