Javascript Articles

Page 504 of 534

How to use typeof with arguments in JavaScript?

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

The arguments object contains all parameters passed to a function. You can use typeof to check the data type of individual arguments or the arguments object itself. Understanding the arguments Object The arguments object is array-like and accessible within all functions. You can access individual arguments using bracket notation: arguments[0] // First argument arguments[1] // Second argument Using typeof with the arguments Object When you use typeof on the arguments object itself, it returns "object": function testArguments() ...

Read More

What is arguments object in JavaScript?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 294 Views

The arguments object in JavaScript is an array-like object that contains all the arguments passed to a function. It allows functions to accept a variable number of parameters and access them dynamically. Syntax arguments[index] arguments.length Properties The arguments object has two main properties: length - Returns the number of arguments passed to the function index - Access individual arguments using bracket notation (0-based) Basic Example ...

Read More

How to show a foreach loop using a flow chart in JavaScript?'

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 1K+ Views

A forEach loop in JavaScript iterates through each element of an array, executing a callback function for every item. Understanding its flow helps visualize how iteration works. forEach Loop Flow Chart Start Initialize array and index Index < Array Length? Execute callback function ...

Read More

How to use OR condition in a JavaScript IF statement?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 5K+ Views

To use OR condition in JavaScript IF statement, use the || operator (Logical OR operator). The condition becomes true if any of the operands is truthy. Syntax if (condition1 || condition2) { // Code executes if either condition1 OR condition2 is true } Basic OR Example var a = true; var b = false; document.write("(a || b) => "); result = (a || b); document.write(result); (a || b) => true Practical IF Statement with OR ...

Read More

What is for each...in a statement in JavaScript?

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

The for each...in loop was a non-standard JavaScript feature that iterated over the values of object properties. However, it has been deprecated and removed from modern JavaScript engines. Important: The for each...in statement is deprecated and no longer supported. Use modern alternatives like for...of, Object.values(), or forEach() instead. Syntax (Deprecated) The original syntax was: for each (variablename in object) { statement or block to execute } Why It Was Deprecated The for each...in statement was: Non-standard and only supported in Firefox Confusing because it mixed concepts from ...

Read More

How to edit a JavaScript alert box title?

Vrundesha Joshi
Vrundesha Joshi
Updated on 15-Mar-2026 7K+ Views

It's not possible to edit a JavaScript alert box title due to security restrictions in web browsers. The native alert() function creates a modal dialog with a predefined title (usually "Alert" or the domain name) that cannot be customized. To create custom alert boxes with editable titles, you need to use alternative approaches like custom JavaScript modal dialogs, CSS frameworks, or specialized libraries. Why Native Alerts Can't Be Customized Browser security policies prevent websites from modifying the alert dialog's appearance to avoid phishing attacks and maintain user trust. The title always shows the browser's default text or ...

Read More

How to create a custom object in JavaScript?

vanithasree
vanithasree
Updated on 15-Mar-2026 589 Views

JavaScript offers multiple ways to create custom objects. Each method has its own syntax and use cases, making JavaScript flexible for object-oriented programming. Method 1: Using Object Constructor The new Object() constructor creates an empty object that you can populate with properties: var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology = "Java"; ...

Read More

What is super() function in JavaScript?

radhakrishna
radhakrishna
Updated on 15-Mar-2026 333 Views

The super() function in JavaScript is used to call the constructor of the parent class and access methods from the parent class within a child class. It's essential for proper inheritance in ES6 classes. Syntax super() // Call parent constructor super.method() // Call parent method Using super() in Constructor When extending a class, you must call super() before using this in the child constructor: ...

Read More

How to call a JavaScript function on submit form?

mkotla
mkotla
Updated on 15-Mar-2026 16K+ Views

The onsubmit event occurs when you try to submit a form. You can put your form validation against this event type. The following example shows how to use onsubmit. Here we are calling a validate() function before submitting a form data to the webserver. If validate() function returns true, the form will be submitted, otherwise it will not submit the data. Basic Syntax Method 1: Using onsubmit Attribute The most common approach is to use the onsubmit attribute directly in the form ...

Read More

How to provide new line in JavaScript alert box?

Rishi Rathor
Rishi Rathor
Updated on 15-Mar-2026 829 Views

To add a new line in JavaScript alert box, use the "" escape character: Syntax alert("First lineSecond line"); Basic Example function showAlert() { alert("This is line oneThis is line twoThis is line three"); } Click to Show Alert Multiple Line Breaks You ...

Read More
Showing 5031–5040 of 5,340 articles
« Prev 1 502 503 504 505 506 534 Next »
Advertisements