Using .includes method in a function : <p>I have a an object <code>jsonRes[0]</code> containing values which need to be removed based on a condition.  The following works to remove <code>null</code>,  missing values and those equal to zero in the stringified object: </p>

<pre><code>function replacer(key, value) {
          // Filtering out properties
          if (value === null || value === 0 || value === "") {
            return undefined;
          }
          return value;
        } 

JSON.stringify(jsonRes[0], replacer, "\t")
</code></pre>

<p>However, when I add a condition using the the <code>includes</code> method, I receive an error:</p>

<pre><code>function replacer(key, value) {
          // Filtering out properties
          if (value === null || value === 0 || value === "" || value.includes("$")) {
            return undefined;
          }
          return value;
        } 


Uncaught TypeError: value.includes is not a function
</code></pre>

<p>Why is this the case and is there a workaround? </p>
