Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在javascript中调用str.replace()时,会出现错误ir未定义_Javascript_Str Replace - Fatal编程技术网

在javascript中调用str.replace()时,会出现错误ir未定义

在javascript中调用str.replace()时,会出现错误ir未定义,javascript,str-replace,Javascript,Str Replace,看到我的代码了吗 for (var i = 0; i < allTextLines.length; i++) { var row_data = allTextLines[i]; console.log(row_data); row_data = row_data.replace(/ /g,''); try { ir(row_data == "")

看到我的代码了吗

for (var i = 0; i < allTextLines.length; i++) {
            var row_data = allTextLines[i];
            console.log(row_data);
            row_data = row_data.replace(/ /g,'');
            try {

                ir(row_data == "")
                {
                    continue;
                }
                if (document.getElementById("devicesList").value.length > 0) {
                    document.getElementById("devicesList").value += ",";
                }
                document.getElementById("devicesList").value += row_data;
            }
            catch (oErr) {
                not_read += 1;
                console.log(oErr.message);
                str_error_detail_rows += "<tr><td colspan='2'>Error :" + oErr.message + " could not read line# " + i + " while reading from file.</td></tr>";
            }

        }
当我运行代码时,在控制台中我得到的ir未定义,请有人帮助我。当我删除str.replace时,代码运行平稳。谢谢

ir(row_data == "") 
应该是

if(row_data == "")
我认为ir应该是一个if,这是一个输入错误


坦率地说,你真的可以通读一遍,并在注意的同时立即注意到问题

这个错误意味着你试图调用的函数ir没有定义。函数ir在哪里?@Pointy这是if的拼写错误。你不是说if,不是ir吗?@JLRishe抱歉,我刚刚醒来:解决错误[something]的第一步是查看代码中的[something]。它会的,但在我填写答案以达到最小字符限制时,它不在那里。