the properties given in the function are not visible in its interior

时间:2019-04-16 22:24:54

标签: javascript

I have functions

      const change = (nameInput, nameError, nameRegexp) => {
        return () => {
          const val = nameInput.value;
          if (!regexp.nameRegexp.test(val)) {
            error.classList.add('animation');
            error.innerHTML = errorMessage.nameError;
            nameInput.classList.remove('correct');
          } else {
            nameInput.classList.add('correct');
            error.classList.remove('animation');
          }
        }
      }
lastName.addEventListener('change', change(lastName, name, name));

The problem is that the nameError, nameRegexp properties are not visible in the middle of the function.

Why is this happening? How to fix this error?

0 个答案:

没有答案