Where is JavaScript.getCurrent().addFunction(String, JavaScriptFunction) in

Hello. You can declare a [@ClientCallable]
(https://vaadin.com/docs/v14/flow/element-api/client-server-rpc.html#calling-server-side-methods-from-the-client) method in the Java class

@ClientCallable
public String getGreeting(String name) {
    return "Hello " + name;
}

and invoke it from client-side code as

getServerGreeting() {
  let greetingPromise = this.$server.getGreeting("JavaScript");
  greetingPromise.then(greeting => console.log(greeting));
}