Passing null as a param for replace() in javascript behaving weird?
Posted
by Babiker
on Stack Overflow
See other posts from Stack Overflow
or by Babiker
Published on 2010-06-16T04:07:30Z
Indexed on
2010/06/16
4:12 UTC
Read the original article
Hit count: 326
I have the follwing jQuery:
$("#textArea").keyup(function(){
var textAreaValue = $("textArea");
if(!textArea.value.indexOf("some string")){
textArea.value = textArea.value.replace("some string",null);
alert("It was there!");
}
});
Is it normal for
element.value.replace("some string",null);to replace"some string"with"null"as a string? And if normal can you please explain why?I have tested it with
element.value.replace("some string",""), and that works fine, so what would be the difference betweennulland""?
Thanks in advance.
© Stack Overflow or respective owner