Front End Technology Articles

Page 541 of 652

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

Rahul Sharma
Rahul Sharma
Updated on 13-Jun-2020 238 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 −                              

Read More

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

Johar Ali
Johar Ali
Updated on 13-Jun-2020 554 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

What is Addition Operator (+) in JavaScript?

Anvi Jain
Anvi Jain
Updated on 13-Jun-2020 331 Views

The addition operator is used to add two operands.ExampleYou can try to run the following code to work with Addition Operator −                    var a = 33;          var b = 10;          document.write("a + b = ");          result =a + b;          document.write(result);          

Read More

What is Addition Assignment Operator (+=) in JavaScript?

Nitya Raut
Nitya Raut
Updated on 13-Jun-2020 286 Views

It adds the right operand to the left operand and assigns the result to the left operand.ExampleYou can try to run the following code to learn how to work with Addition Assignment Operator −                    var a = 33;          var b = 10;          document.write("Value of a => (a += b) => ");          result = (a += b);          document.write(result);          document.write(linebreak);          

Read More

How to declare boolean variables in JavaScript?

Amit Sharma
Amit Sharma
Updated on 13-Jun-2020 682 Views

A boolean variable in JavaScript has two values True or False.ExampleYou can try to run the following code to learn how to work with Boolean variables −           35 > 20       Click for result                      function myValue() {             document.getElementById("test").innerHTML = Boolean(35 > 20);          }          

Read More

How to declare numbers in JavaScript?

Ali
Ali
Updated on 13-Jun-2020 5K+ Views

JavaScript is untyped language. This means that a JavaScript variable can hold a value of any data type. To declare variables in JavaScript, you need to use the var keyword. Whether it is a number or string, use the var keyword for declaration.Here’s how you can declare numbers in JavaScript −var points = 100; var rank = 5;ExampleYou can try to run the following code to learn how to declare number in JavaScript −                                

Read More

What is unsigned Right Shift Operator (>>>) in JavaScript?

Nancy Den
Nancy Den
Updated on 13-Jun-2020 593 Views

This operator is just like the >>operator, except that the bits shifted in on the left are always zero i.e. xeroes are filled in from the left.ExampleYou can try to run the following code to learn how to work with unsigned right shift operator −                    var a =-14;          var b =2; // Shift right two bits          document.write("(a >>> b) => ");          result =(a >>> b);          document.write(result);          

Read More

How and why to avoid global variables in JavaScript?

Ali
Ali
Updated on 13-Jun-2020 1K+ Views

Avoid global variables or minimize the usage of global variables in JavaScript. This is because global variables are easily overwritten by other scripts. Global Variables are not bad and not even a security concern, but it shouldn’t overwrite values of another variable.On the usage of more global variables in our code, it may lead to a maintenance issue. Let’s say we added a variable with the same name. In that case, get ready for some serious bugs.To avoid the usage of global variables, use the local variables and wrap your code in closures. You can also avoid this by wrapping ...

Read More

How to write inline JavaScript code in HTML page?

Rahul Sharma
Rahul Sharma
Updated on 13-Jun-2020 763 Views

Inline JavaScript Code − If you are adding some JavaScript code in an HTML file without using the src tag then it is known as inline JavaScript code. That’s all you need to know.

Read More

Is it better to have one big JavaScript file or multiple light files?

Amit Sharma
Amit Sharma
Updated on 13-Jun-2020 1K+ Views

To avoid multiple server requests, group your JavaScript files into one. Whatever you use for performance, try to minify JavaScript to improve the load time of the web page.If you are using single page application, then group all the scripts in a single file.If you are using multiple files, then minify all of your scripts and separate them into categories.example - Place JavaScript to be used in every page. This can be the core script of the file. - Place your plugins hereRest, add other scripts in a JavaScript file. It’s good to maintain it in different files.

Read More
Showing 5401–5410 of 6,517 articles
« Prev 1 539 540 541 542 543 652 Next »
Advertisements