How to replace an apostrophe in a string in Javascript?

Viewed 59413

Given a string in Javacript, such as

var str = "this's kelly";

I want to replace the apostrophe (') with another character. Here is what I've tried so far:

str.replace('"', 'A');
str.replace('\'', 'A');

None of these work.

How do I do it?

Can you also please advices me with the invalid characters that when passed to the query string or URL crashes the page or produces undesired results ? e.g passing apostrophe (') produces undesired result are their any more of them.

3 Answers
Related