首页 > 解决方案 > 在使用 JavaScript 的 HTML 的结果中获得了 `function () { [native code] }` 值

问题描述

我在 HTML 结果中得到function () { [native code] }值。

function getWarning(type)从警告数组中按类型获取警告。
function getCaches()从缓存数组中获取所有缓存的警告。
function cacheWarning(type)如果不在缓存数组中,则添加缓存警告。

JavaScript:

    var warnings=['- Le nom très petite !','- Cette prénom très petite ! !',"- Votre age invalide, le moin de l'age est 18 !","- Le numéro de téléphone incorrect !",'- Email invalide !',"- Le mot de pass doit de contient les caractéres et les nombres !",'- Le mot de pass sans confirmer !'];
    var caches=new Array("");
    var i=0;
    function getWarning(type){
         i=0;
         for(i in warnings){
               if(warnings[i].includes(type)){return warnings[i];}
         }
    }
    function getCaches(){
          let allCaches="";
          i=0;
          for(i in caches){
             allCaches+=caches[i]+"<br/>";
          }
          return allCaches;
    }
    function cacheWarning(type){
        i=0;
        for(i in caches){
        if(caches[i]==getWarning(type)){
            return -1;
            }
        }
        caches[caches.length]=getWarning(type);
     }

if(document.getElementsByName("prenom")[0].value.length<=2){if(cacheWarning("prénom")!=-1){$("#content").html(getCaches())}}

调试结果: 这是屏幕截图解释变量'i'是NaN,我在从导航器检查元素后得到它

HTML 结果: 这是来自导航器的屏幕截图解释 HTML 的结果

标签: javascriptarraysalgorithmnan

解决方案


推荐阅读