Java Script: Difference between methodName and methodName()

In JavaScript, there is a difference between object.methodName and object.methodName().  By defining the last parenthesis calls the method, where the first one refers to the methodName method instance.  So in code, if doing the following:

if (object.methodName() == undefined)

is checking for whether the returned type is undefined, where the following:

if (object.methodName == undefined)

is checking whether a method is undefined for that given type.  if trying to see if a method exists, and you specify the () at the end, an exception will occur.

Comments

No Comments