यह जांचने के लिए कि JavaScript फ़ंक्शन परिभाषित है या नहीं, इसे "undefined" के साथ जांचें।
उदाहरण
<!DOCTYPE html> <html>
<body>
<script>
function display() {
alert("Hello World!");
}
if (typeof(display) === 'undefined') {
document.write('undefined');
} else {
document.write("Function is defined");
}
</script>
</body>
</html>