Can js throw be followed by a string?

function getRectArea(width, height) {
  if (isNaN(width) || isNaN(height)) {
    throw "err"
  }
}
try {
  getRectArea(3, "A")
} catch (e) {
  console.log(e)
}

when I use such a piece of code, I will report an error: Expected an object to be thrown;
I have no problem executing this code in the console, and the above error will occur in the editor. I don"t know what the problem is and whether it is caused by my eslint configuration.

Mar.23,2021
If you have any problems with

, you can first query the api document. throw statement
throw supports strings, numbers, Boolean values, and objects.
Expected an object to be thrown translates into Chinese that an object is expected to be thrown. Eslint configuration problem


@ onlookers is indeed an eslint configuration problem. Add "no-throw-literal": 0 to the rules object in the eslint configuration and you can

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4902f-44ceb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4902f-44ceb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?