JavaScript suppress a specific error
<p>I have the following line in my JavaScript file, which creates an error message on the console:</p>

<pre><code>myObject.width = 315;
</code></pre>

<p>I want to hide this error message on the console. I mean that, this line of code will run, it will give error, but won't display it on the console log.</p>

<p>I read about <code>window.onerror</code>, but it did not work. As I understand, this disables all the errors on a page, however I want to disable the errors of only my line. I tried putting it right after, but it didn't work either:</p>

<pre><code>myObject.width = 315;
window.onerror = function(){
       return true;
    }
</code></pre>

<p>Is there any workaround for this? Thanks.</p>