Why is my JavaScript code behaving strange?
<p>Could someone explain why delete works in second function not in first?</p>

<pre><code>var myFunction = (function (val) {
    delete val;
    return val;
})(10);
console.log(myFunction);


var myFunction1 = (function () {
    myVar = "test"
    delete myVar;
    return myVar;
})();
console.log(myFunction1);
</code></pre>
