If you know what type you expect, you can use instanceOf. For example:
if (!(serialPort instanceof Serial)) {throw '"serialPort" parameter is not a serial port!'}
if (!(rxPin instanceof Pin)) {throw '"rx" parameter is not a Pin!';}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
If you know what type you expect, you can use
instanceOf
. For example: