开发者

What does match function return because split is failing?

Via alert I have the information string 1:CX.PC.PB.0012.S.S which is from alert(c_itemvalue);

Then I have the line: var arr = c_itemvalue.split(':');

In Firefox I am getting an error c_itemvalue.split(':') is not a function.

Usually the only time I get not a function errors is when I'm trying to pass a variable o开发者_开发知识库f an invalid type (like is c_itemvalue was an integer) but this time the variable is the return from a match function so I assume that is a string value.

Am I missing something else here?


Try this:

var arr = c_itemvalue.toString().split(':');

The c_itemvalue might be not a string object


The "match" function returns an array. The "alert" call will always ".toString()" its argument.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜