Web Development Articles

Page 331 of 801

Why JavaScript Data Types are Dynamic?

Sravani S
Sravani S
Updated on 15-Mar-2026 281 Views

JavaScript is a dynamically typed language, which means variables can hold different data types during program execution. Unlike statically typed languages where you must declare a variable's type upfront, JavaScript determines the type at runtime based on the assigned value. What Does Dynamic Typing Mean? In JavaScript, you don't need to specify whether a variable will store a string, number, or boolean. The same variable can be reassigned to hold completely different data types throughout the program. Example var val; ...

Read More

How to create Empty Values String in JavaScript?

seetha
seetha
Updated on 15-Mar-2026 3K+ Views

In JavaScript, there are several ways to create empty string values. An empty string is a string with zero characters, represented by two quotation marks with nothing between them. Syntax let emptyString = ""; // Double quotes let emptyString = ''; // Single quotes let emptyString = ``; // Template literals let emptyString = String(); // String constructor Example: Creating Empty Strings ...

Read More

How to call a function in JavaScript?

Nancy Den
Nancy Den
Updated on 15-Mar-2026 1K+ Views

JavaScript allows us to write our own functions as well. To invoke a function somewhere later in the script, you would simply need to write the name of that function. Function Declaration Before calling a function, you need to declare it. Here's the basic syntax: function functionName() { // Code to execute } Calling a Function Once declared, you can call a function by writing its name followed by parentheses: function sayHello() ...

Read More

How to write JavaScript Regular Expression for multiple matches?

Nikitha N
Nikitha N
Updated on 15-Mar-2026 281 Views

To find multiple matches in JavaScript, use the global flag (g) with regular expressions. The exec() method can be called repeatedly to find all matches in a string. Syntax let regex = /pattern/g; let matches; while ((matches = regex.exec(string)) !== null) { // Process each match } Example: Extracting URL Parameters This example extracts all demo parameters from a URL query string: var url = 'https://www.example.com/new.html?ui=7&demo=one&demo=two&demo=three'; var a = document.createElement('a'); a.href = url; var demoRegex = /(?:^|[&;])demo=([^&;]+)/g; var matches; var demo = []; ...

Read More

What is function overloading in JavaScript?

Ankitha Reddy
Ankitha Reddy
Updated on 15-Mar-2026 2K+ Views

JavaScript does not support function overloading like other programming languages such as Java or C++. When you define multiple functions with the same name, JavaScript keeps only the last defined function. What Happens with Same Function Names Let's see what happens when we define multiple functions with the same name: function funcONE(x, y) { return x * y; } function funcONE(z) { return z; } // Only the last function definition is kept console.log(funcONE(5)); // prints 5 console.log(funcONE(5, 6)); // prints ...

Read More

How much should be a JavaScript Line Length?

Nitya Raut
Nitya Raut
Updated on 15-Mar-2026 846 Views

JavaScript line length refers to how many characters should fit on a single line of code. Following proper line length guidelines makes your code more readable and maintainable. Recommended Line Length The standard practice is to keep JavaScript lines under 80 characters. Some modern style guides allow up to 100 or 120 characters, but 80 remains the most widely adopted standard for better readability across different editors and devices. Breaking Long Lines When a statement exceeds the character limit, break it after a comma or operator, not in the middle of a variable name or string. ...

Read More

How to set whether the style of the font is normal, italic or oblique with JavaScript?

Jai Janardhan
Jai Janardhan
Updated on 15-Mar-2026 190 Views

To set the style of the font in JavaScript, use the fontStyle property. This property accepts three values: normal, italic, and oblique. Syntax element.style.fontStyle = "normal" | "italic" | "oblique"; Example: Setting Font Style to Italic This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This is Demo Text. This ...

Read More

How to set an image as the list-item marker with JavaScript?

Monica Mona
Monica Mona
Updated on 15-Mar-2026 223 Views

To set an image as the marker in list items, use the listStyleImage property in JavaScript. This property allows you to replace default list markers (bullets or numbers) with custom images. Syntax element.style.listStyleImage = "url('image-path')"; Example The following example demonstrates how to set a custom image as the list-item marker: First Item Second Item Third Item ...

Read More

How to set the right margin of an element with JavaScript?

Jai Janardhan
Jai Janardhan
Updated on 15-Mar-2026 677 Views

Use the marginRight property in JavaScript to set the right margin of an element. This property accepts values in pixels, percentages, or other CSS units. Syntax element.style.marginRight = "value"; Example #myID { border: 2px solid #000000; background-color: #f0f0f0; padding: 10px; } ...

Read More

Setting null values with an HTML using AngularJS.

Arjun Thakur
Arjun Thakur
Updated on 15-Mar-2026 202 Views

In AngularJS, setting null values in select dropdowns requires proper model initialization and template configuration. This approach is useful when you want to handle undefined or empty selections. Controller Setup First, define the controller with a null-initialized model and populate the options array: function display($scope) { $scope.obj = {"selected": null}; $scope.objects = [{id: 1, value: "Yes"}, {id: 0, value: "No"}]; } HTML Template The template uses ng-options to populate the dropdown and includes a default "Unknown" option: ...

Read More
Showing 3301–3310 of 8,010 articles
« Prev 1 329 330 331 332 333 801 Next »
Advertisements