简体   繁体   English

Javascript尝试捕获错误-预期功能

[英]Javascript try catch error - function expected

I am developing windows app in windows phone Silverlight 8.1 solution. 我正在Windows Phone Silverlight 8.1解决方案中开发Windows应用程序。

when i am using the try catch i get error saying funtion expected. 当我使用try catch时,出现错误,提示预期功能。

Here is my piece of code: 这是我的代码:

try
{
    alert("blogCategoryId is : " + blogCategoryId.length());
}
catch (err) {
    alert("Error is :" + err.message);
}

And is there alternative of .length() funtion. 还有.length()函数的替代方法。

I wanted to get the each element of blogCategoryId if the elements are more than 1, and i got it with the following code: 如果元素大于1,我想获取blogCategoryId的每个元素,并使用以下代码获取它:

if (blogCategoryId.length>1)
{
    var digits = ("" + blogCategoryId).split("");
    for (var i = 0; i < digits.length; i++) {
        alert("The length is greater :"+digits[i]);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM