- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10711 Articles for Web Development
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
155 Views
On getting the result of the following, you can find whether a variable is ‘undefined’. If the result is “false”, it means the variable is undefined. Here, the variable results in “True” Example Live Demo var res = 10; if(res) { document.write("True"); } else { document.write("False"); }
![Amit Sharma](https://www.tutorialspoint.com/assets/profiles/14294/profile/60_103411-1513053466.png)
175 Views
To generate a random number, use the JavaScript Math.random() method. Here set the minimum and maximum value and generate a random number between them as in the following code −ExampleLive Demo var max = 6 var min = 2 var random = Math.floor(Math.random() * (max - min + 1)) + min; document.write(random)
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
8K+ Views
In this tutorial, we will learn how to pass JavaScript Variables with AJAX calls. AJAX stands for Asynchronous JavaScript and XML. As the name suggests, it performs asynchronous operations on your web page. AJAX communicates with the server by HTTP requests and gets the required data as an HTTP response. We can control these HTTP requests by passing the JavaScript variables with AJAX calls. There are various types of HTTP requests, and in this tutorial, we will discuss the most popular HTTP requests by using AJAX and also pass JavaScript variables with it. Pass JavaScript Variables with “GET” AJAX calls ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
Like many other programming languages, JavaScript has variables. Variables can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container.JavaScript variables get stored in the memory of the browser process. The following ways can work for storing variables:The variables which you declare in your JavaScript code gets saved in the memory of the browser process.Cookies can also store variables, they are often saved on your hard disk;
![Amit Sharma](https://www.tutorialspoint.com/assets/profiles/14294/profile/60_103411-1513053466.png)
125 Views
Definitely, the following way of declaring multiple variables is more efficient:var variable1 = 5; var variable2 = 3.6; var variable3 = “Amit”;Suppose you need to add, remove, or update a variable, then you can easily do it.But with the following method, you need to do more changes. For example, on removing a variable, you need to remove the semi-colon. If it’s the first, then you need to add var to the second variable.var variable1 = 5, variable2 = 3.6, variable3 = “Amit”
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
1K+ Views
In this tutorial, we will look at a few ways to prevent duplicate JavaScript variable declarations and comparison between them from understanding which one is suitable in a given context. The best way to prevent duplicate variable declaration is to avoid creating global variables. Let’s move forward to discuss this. Wrapping Code Within a Function Here, the variables declared inside the function are not accessible outside the function and vice versa. Users can follow the syntax below for using this method. Syntax (function(){ var varNam = "test"; }()) Here varNam is wrapped inside a function. Example ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
4K+ Views
In this tutorial, we will learn different approaches to checking if a JavaScript variable is of function type or not. In JavaScript, the function contains the block of code, making the code reusability better.There are mainly two ways to declare the functions, one is a named function, and another is an anonymous function. While declaring the anonymous function, we need to store it in some variable to access it from somewhere in our code or call that function.Here, users can see how to declare the anonymous function and store it into the variable.let tutorialspoint = function() { //code for the ... Read More
![Sai Subramanyam](https://www.tutorialspoint.com/assets/profiles/13512/profile/60_68191-1512710774.jpg)
16K+ Views
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 } }
![Swarali Sree](https://www.tutorialspoint.com/assets/profiles/13515/profile/60_84115-1512649510.jpg)
600 Views
On getting the result of the following, you can find whether a variable is null or undefined. If the result is “false”, it means the variable is null and undefined.Here, the variable results in “True” − var age = 10; if(age) { document.write("True"); } else { document.write("False"); }
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
6K+ Views
In this article, we will learn what characters are valid for JavaScript variable names. We use variables to save values. First, we have to define the variable, and then we can assign a value to it. We can use the variable name to access the variable in the code. With a variable name, we can reassign its value. As you adhere to a few principles, variable names are quite versatile. Rules A letter, dollar sign($), or underscore (_) must make up the first character. A number cannot be the initial character. Any letter, number, or underscore can complete the ... Read More