Is there a way to let a javascript function know that a certain parameter is of a certain type?
Being able to do something like this would be perfect:
Use typeof or instanceof:
typeof
instanceof
const assert = require('assert'); function myFunction(Date myDate, String myString) { assert( typeof(myString) === 'string', 'Error message about incorrect arg type'); assert( myDate instanceof Date, 'Error message about incorrect arg type'); }