yicr
2/21/2020 - 6:45 AM

How to check if function exists in JavaScript?

inteeface method exist!

if (typeof me.onChange !== "undefined") { // safe to use the function }

if (typeof me.onChange === "function") { // safe to use the function }

if (typeof me.onChange !== "undefined" && typeof me.onChange === "function") { }