1

in javascript after i add some data in to object type

key undefined

here is my code

let ErrName = {};

formSchema.validate(values, { abortEarly: false }).catch(function (err) {
  err.inner.forEach((e) => {
    ErrName[e.path] = e.message;
  });
  return ErrName;
});
    
console.log(ErrName);

this is my result in console

{}
email: "Email is required"
password: "Password is required"
[[Prototype]]: Object

   console.log(ErrName.email);

undefined
Phil
  • 157,677
  • 23
  • 242
  • 245
en nice
  • 31
  • 1
  • 2
  • Don't use the console for debugging, [it does not always represent the truth](https://stackoverflow.com/questions/7389069/how-can-i-make-console-log-show-the-current-state-of-an-object) – Phil Oct 24 '21 at 22:46
  • even in return

    {ErrName.email}

    does not show anything
    – en nice Oct 25 '21 at 09:48

0 Answers0