How do I invoke JavaScript in AjaxResponse?
Best way is probably to add your own custom command :

&lt;?php
namespace Drupal\demo_test\Ajax;
use Drupal\Core\Ajax\CommandInterface;
class DemoTestJsCommand implements CommandInterface
{
    public function render(){
        return [
            'command' =&gt; 'demoTestJsCommand',
        ];
    }

}


And JS :

Drupal.AjaxCommands.prototype.demoTestJsCommand = function (ajax, response) {
    alert(1);
};


Then, you just have to add 

$response-&gt;addCommand(new DemoTestJsCommand());


in you form's response.