When is it too difficult to check function arguments?

Is it redundant to check function arguments before continuing?

eg.

var doFoo = function(id, message){
     // Are these asserts overkill?
     goog.asserts.assertNumber(id, "Expecting a numeric id.");
     goog.asserts.assertString(message, "Expecting a string.");

    // Do more stuff here
}

Note. This is using the closing library statement statements, but any such logic can use any library or no library at all, you get the idea.

EDIT: I think this question is subjective. The best question would be ... When is it too difficult to check function arguments? I think.

+4
source share
1 answer

, . . ( ). , , , , sidet

0

Source: https://habr.com/ru/post/1526752/


All Articles