

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to unset a JavaScript variable?
To unset a variable in JavaScript, use the undefined. After that, use delete operator to completely remove it.
Let’s try the code snippet again.
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 } }
- Related Questions & Answers
- How to unset a variable in MongoDB shell?
- How to unset objects in MongoDB?
- How to check if a variable exists in JavaScript?
- How to check a not-defined variable in JavaScript?
- How to define global variable in a JavaScript function?
- Python program to count unset bits in a range.
- How can we assign a function to a variable in JavaScript?
- How to check if a variable is NaN in JavaScript?
- How to load a JavaScript function using the variable name?
- How to check if a variable is boolean in JavaScript?
- How to execute a JavaScript function using its name in a variable?
- Various ways to define a variable in JavaScript
- Count unset bits in a range in C++
- Count unset bits of a number in C++
- How to check if a variable is an integer in JavaScript?
Advertisements