如何在调用之前检查函数“App.ServisTanimId.getValue”是否作为属性存在?

How to check whether the function “App.ServisTanimId.getValue” exists as a property before calling it?

我的 CSHTML 中有一个 JavaScript 代码。当我单击按钮时,它会运行一个函数。但在某些windows中App.ServisTanimId.getValue()undefined。这就是为什么我的按钮不起作用。有什么方法可以检查 App.ServisTanimId.getValue() 是否未定义然后才执行它?

Pencere = function(parameters) {
  Ext.net.directRequest({
    url: '@(Url.Action("window", "Home", new { Area = "area" }))',
    extraParams: {
      ServisTanimId: App.ServisTanimId.getValue(),
      CepDepoTanimId: App.CepDepoTanimId.getValue()
    },
    eventMask: {
      showMask: true
    }
  });
};
if(App.ServisTanimId) {
  // This code will execute if App.ServisTanimId is defined
} else {
  // If undefined
}

应该可以