Can someone explain what this piece of code does. what is the test function testing for?
temp = "blah"
if ( /from_url=$/.test(temp) ) {
//do something
}
test : function(s, p) {
s = s.nodeType == 1 ? s.value : s;
return s == '' || new RegExp(p).test(s);
}
Also in the initial condition what does the syntax if(/from_url=$/) do?
s = s.nodeType == 1 ? s.value : s;
if s.nodeType is 1 then use s.value, otherwise use s.
return s == '' || new RegExp(p).test(s);
return s if it's an empty string, otherwise test if s is in the regular expression p.
if(/from_url=$/)
is a regular expression that is looking for from_url=
but only if it is at the very end.