detect if function exists javascript code example Example: check if function exists javascript if (typeof payment === "function") { // Do something }