To access data and controls of a form with JavaScript you have to use the Client API executionContext.
First get the formContext object.
var formContext = executionContext.getFormContext();
To access form data for example the value of the field firstname use the formContext.data.entity.attributes object.
var formContext = executionContext.getFormContext(); var firstName = formContext.data.entity.attributes.get("firstname").getValue(); // Or var firstName = formContext.getAttribute("firstname").getValue();
To access the controls themselves for example to hide them use the formContext.ui.controls object.