Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/424.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 仪器与索引_Javascript_Function_Vbscript_Indexof_Instr - Fatal编程技术网

Javascript 仪器与索引

Javascript 仪器与索引,javascript,function,vbscript,indexof,instr,Javascript,Function,Vbscript,Indexof,Instr,此ASP InStr函数是否等效于js indexOf函数: ASP: 不,只有一例是相同的。若找不到值InStr返回0和indexOf return-1,但InStr还有许多其他值,请查看 差异 InStr函数返回一个字符串在另一个字符串中第一次出现的位置 InStr函数可以返回以下值: If string1 is "" - InStr returns 0 If string1 is Null - InStr returns Null If string2 is "" - InStr retu

此ASP InStr函数是否等效于js indexOf函数:

ASP:


不,只有一例是相同的。若找不到值InStr返回0和indexOf return-1,但InStr还有许多其他值,请查看

差异

InStr函数返回一个字符串在另一个字符串中第一次出现的位置

InStr函数可以返回以下值:

If string1 is "" - InStr returns 0
If string1 is Null - InStr returns Null
If string2 is "" - InStr returns start
If string2 is Null - InStr returns Null
If string2 is not found - InStr returns 0
If string2 is found within string1 - InStr returns the position at which match is found
If start > Len(string1) - InStr returns 0
而javascript
indexOf()
方法返回字符串中指定值第一次出现的位置

This method returns -1 if the value to search for never occurs.

如果您只想检查
var1
中是否存在
var2
(带
之前和
之后),那么它们是等效的,是的。问题解决了!
If string1 is "" - InStr returns 0
If string1 is Null - InStr returns Null
If string2 is "" - InStr returns start
If string2 is Null - InStr returns Null
If string2 is not found - InStr returns 0
If string2 is found within string1 - InStr returns the position at which match is found
If start > Len(string1) - InStr returns 0
This method returns -1 if the value to search for never occurs.