Thursday, January 12, 2012

Reference syntax does not match behavior for replace()


The function below does not work unless I assume that .replace returns the new string. The syntax implies that the input string itself it modified.



MDN




str.replace(regexp|substr, newSubStr|function[, Non-standardflags]);



Code




escape: function ( second_split )
{
for( element in second_split )
{
second_split[element] = second_split[element].replace('**', '*');
second_split[element] = second_split[element].replace('*|', '|');
}
return second_split;
},

No comments:

Post a Comment