Found 10711 Articles for Web Development

How is JavaScript an interpreted language?

Saurabh Jaiswal
Updated on 05-Jan-2023 15:31:45

3K+ Views

JavaScript is a lightweight and interpreted language, therefore, inside the context of a web browser, you don't even need to buy a compiler. You can start with a simple text editor such as Notepad. To make our life simpler, various vendors have come up with very nice JavaScript editing tools. Some of them are listed here − Microsoft FrontPage − Microsoft has developed a popular HTML editor called FrontPage. FrontPage also provides web developers with a number of JavaScript tools to assist in the creation of interactive websites. Macromedia Dreamweaver MX − Macromedia Dreamweaver MX is a very popular ... Read More

What happens when you do not declare a variable in JavaScript?

Ali
Ali
Updated on 13-Jun-2020 09:23:31

149 Views

Yes, this can be done. When you have a global scope, you can use a variable without declaring it. The following “no var” variable “points” will look at the scope chain, wince var keyword isn’t use −                    var rank = 5;          points = 50;          marks = 300;          // Anonymous function          (function() {             points = 100; //overwrites global scope points             var rank = 4; //new rank variable is created in this' function's scope             var marks = 900;             document.write(rank+"\r"); //prints 4             document.write(points+"\r"); //prints 100             document.write(marks+"\r"); //prints 900          })();          document.write('');          document.write('');          document.write(rank+"\r"); //prints 5          document.write(points+"\r"); //prints 100          document.write(marks+"\r"); //prints 300          

Variable Hoisting in JavaScript

Rahul Sharma
Updated on 13-Jun-2020 09:22:57

169 Views

When you can use a JavaScript variable before it is declared, it is done using a technique called hoisting. The parser read through the complete function before running it.The behavior in which a variable appears to be used before it is declared is known as hoisting −For example, the following,points =200; var points;The above works the same like the following −var points; ponts = 200;

What is $(document).ready() equivalent in JavaScript?

Johar Ali
Updated on 13-Jun-2020 09:15:10

2K+ Views

In jQuery, if you want an event to work on your page, you should call it inside the $(document).ready() function. Everything inside it will load as soon as the DOM is loaded and before the page contents are loaded.$(document).ready(function() {    alert(“Document loaded successful!"); });ExampleIn JavaScript, to achieve the same result like $(document).ready, try the following code −                    var loader = setInterval(function () {             if(document.readyState !== "complete") return;             clearInterval(loader);             alert(“Document loaded successful!");             // document.write("Document loaded successful!");          }, 300);          

How to validate decimal numbers in JavaScript?

Shubham Vora
Updated on 31-Oct-2022 11:03:27

12K+ Views

In this tutorial, we will learn to validate decimal numbers in JavaScript. A number containing decimal(.) is known as a decimal number. A number comes between the two whole numbers, called decimal numbers. We use decimal numbers in calculations, progress bars, to accept input in forms, etc. A regular expression is a well-known entity for validation purposes. A Regular expression is a search pattern of characters with a specific meaning used to validate the data. It can be used for any string or number. We are going to use it for validation purposes in JavaScript. We used a simple logic ... Read More

What happens if we re-declare a variable in JavaScript?

Rahul Sharma
Updated on 13-Jun-2020 08:40:34

123 Views

On re-declaring a variable in JavaScript, the variable value still remains the same.ExampleLet’s see an example. Here, we are declaring the variable age −                              

What is a composite data type i.e. object in JavaScript?

karthikeya Boyini
Updated on 20-Apr-2022 12:36:59

2K+ Views

A data type is known as a composite data type when it represents a number of similar or different data under a single declaration of variable i.e., a data type that has multiple values grouped together. There are mainly three types of composite data types named as below −ObjectArrayFunctionIn this article, we will discuss the first type of composite data type i.e. object.ObjectAn object is a collection of properties i.e, an object can store the properties of anything in the key-value pairs. An object in javascript has keys and each key has its own value as shown in the examplelet ... Read More

What is the difference between Declaring and Initializing a variable in JavaScript?

Johar Ali
Updated on 13-Jun-2020 08:39:29

416 Views

The following is stated about declaration and initialization of a variable in ECMAScript specification −A var statement declares variables that are scoped to the running execution context’s VariableEnvironment. Var variables are created when their containing Lexical Environment is instantiated and are initialized to undefined when created. [...] A variable defined by a VariableDeclaration with an Initializer is assigned the value of its Initializer’s AssignmentExpression when the VariableDeclaration is executed, not when the variable is created.The above defines the difference:All variables are initialized with the value undefined.Variables declarations are initialized with undefined upon the initialization of their lexical environment.This initialization does ... Read More

How to check if a variable exists in JavaScript?

Amit Sharma
Updated on 13-Jun-2020 08:28:18

352 Views

To check if a variable exists in JavaScript, you need to check it against null as in the following code. Here, we’re checking the existence of variable myVar −                    var myVar = 20;          if(myVar !== undefined && myVar !== null) {             document.write("Variable exists");          }          

What is the use of declaring variables in JavaScript?

Ali
Ali
Updated on 13-Jun-2020 08:27:46

86 Views

Before you use a variable in a JavaScript program, you must declare it. 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.Variables are declared with the var keyword as follows.     You can also declare multiple variables with the same var keyword as follows −     This is also you can assign values −var rank = 2; var points = 100;

Advertisements