Unfortunately I don't know JS, but the following C# lines should be easy to be translated.
Animator.GetCurrentAnimatorStateInfo returns an AnimatorStateInfo struct that describes the current animator state.
int stateId = Animator.StringToHash("Base Layer.State Name");
Animator anim = GetComponent<Animator>();
AnimatorStateInfo currentBaseState = anim.GetCurrentAnimatorStateInfo(0);
if (currentBaseState.nameHash == stateId )
{
//you are in stateId
}
Like you see in the example above the animator state's name are hashed (for performance reasons) so you have to hash the name of the state using Animator.StringToHash in order to retrieve the integer id associated with that particular state.