Wednesday, 9 April 2014

Unable to get property 'indexOf' of undefined or null reference

Unable to get property 'indexOf' of undefined or null reference
Solution:
Use if condition.
var myvalu="Hello&Welcome";
var k;
if((myvalu!=null)&&(myvalu!=undefined))
{
if(myvalu.indexOf("&") != -1)
{
k=myvalu.substring(myvalu.lastIndexOf('&')+1);
}
}