Computer Science, asked by Nisha01, 1 year ago

What is the function that always exists and is not first calling function?

Answers

Answered by jatin160
2
When using scripts that are shared between different areas of a site, there may be cases where a function is called that doesn't exist. It makes sense on one page (the dependency is there) but not another. The difference is too slight to warrant forking the file into different versions. Instead, you can just check if the function exists before calling it to avoid the error:
JS
if (typeof yourFunctionName == 'function') {
yourFunctionName();
}
Comments

Great snippet! I keep this in my list of common functions and it’s saved me a million times during development.
I like to add an ‘else’ statement with an alert (or console.log()) to make the failure more visible.
if (typeof yourFunctionName == 'function') {
yourFunctionName();
}else{
alert('Check yourFunctionName!');
}

Harshi124: bye
jatin160: okkk
jatin160: bye
Harshi124: sorry once again..
jatin160: waiting for u
Harshi124: me too
jatin160: if u wana my whtsaap no 8764967249
Harshi124: k sure
jatin160: sure
jatin160: if u interested to chat i wil mess me on whtsaap
Similar questions