Example of JavaScript API in Drupal 8 Module

in a nutshell here is a working example of JavaScript API in Drupal 8 in action.

test_account.libraries.yml

js:
    assets/js/login.js: {}
    dependencies:
      - core/jquery
      - core/jquery.once
      - core/drupal
      - core/drupalSettings

assets/js/login.js:

(function ($, Drupal) {

 console.log(Drupal);
 console.log(drupalSettings);

  Drupal.behaviors.logInForm = {
    attach: function (context, settings) {
     //$('#edit-name') DO some stuff 
       if (drupalSettings.testAccount) {
          var testAccount = drupalSettings.testAccount;
          alert(testAccount.some_pram);
       }
    }
  };

})(jQuery, Drupal);

test_account.module

<?php
/**
 * Implements hook_form_FORM_ID_alter().
 */
function test_account_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  // Add the JS
  $form['#attached']['library'][] = 'test_account/test_account_login';

  // Add Some extra "settings" to use in JS.
  $form['#attached']['drupalSettings']['testAccount'] = array(
    'some_pram' => 'some value'
  );
  
  //$form['#validate'][] = 'test_account_user_validate';
  //$form['#submit'][] = 'test_account_user_login_form_submit';
  $form['actions']['submit']['#disabled'] = TRUE;
}
?>