जावास्क्रिप्ट में एक चर को अनसेट करने के लिए, अपरिभाषित का उपयोग करें। उसके बाद, इसे पूरी तरह से हटाने के लिए डिलीट ऑपरेटर का उपयोग करें।
आइए कोड स्निपेट को फिर से देखें।
var str = “Demo Text”;
window.onscroll = function() {
var y = this.pageYOffset;
if(y > 200) {
document.write(nxt);
nxt = undefined; // unset
delete(nxt); // this removes the variable completely
document.write(nxt); // the result will be undefined
}
}