Programming Scripts Articles

Page 4 of 33

What is the usage of in operator in JavaScript?

Arushi
Arushi
Updated on 15-Mar-2026 200 Views

The in operator is used in JavaScript to check whether a property exists in an object or not. It returns true if the property is found, and false otherwise. Syntax propertyName in object Basic Example Here's how to use the in operator to check for properties in objects: var emp = {name: "Amit", subject: "Java"}; document.write("name" in emp); document.write(""); document.write("subject" in emp); document.write(""); document.write("age" in emp); document.write(""); document.write("MAX_VALUE" in Number); true true false true Checking Array Indices The in ...

Read More

With JavaScript how can I find the name of the web browser, with version?

Abhinaya
Abhinaya
Updated on 15-Mar-2026 391 Views

To find the name of the web browser with version in JavaScript, you can use the navigator object which provides information about the user's browser and system. Basic Browser Detection The traditional approach uses navigator.userAgent to detect browser types: Browser Detection Example var userAgent = navigator.userAgent; var opera = (userAgent.indexOf('Opera') != -1); var ie = (userAgent.indexOf('MSIE') != -1 || ...

Read More

What is the role of throw statement in JavaScript?

Jennifer Nicholas
Jennifer Nicholas
Updated on 15-Mar-2026 241 Views

The throw statement in JavaScript is used to manually create and raise exceptions. When executed, it stops the normal execution flow and passes control to the nearest catch block. Syntax throw expression; The expression can be any value: string, number, boolean, object, or Error instance. Basic Example Here's how to use throw with a simple string message: function checkDivision() { var a = 100; ...

Read More

With JavaScript RegExp find a character except newline?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 299 Views

To find a character except for a newline, use the dot metacharacter . (period). The dot matches any single character except the newline character (). Syntax /./ // Matches any character except newline /.+/ // Matches one or more characters except newline /a.b/ // Matches 'a', any character, then 'b' Example JavaScript Regular Expression ...

Read More

How can I write a script to use either W3C DOM or IE 4 DOM depending on their availability?

Abhinanda Shri
Abhinanda Shri
Updated on 15-Mar-2026 183 Views

If you want to write a script with the flexibility to use either W3C DOM or IE 4 DOM depending on their availability, then you can use a capability-testing approach that first checks for the existence of a method or property to determine whether the browser has the capability you desire. Capability Testing Approach The key is to test for specific DOM methods rather than browser names. This ensures your code works regardless of which browser implements which DOM standard. if (document.getElementById) { // If the W3C method exists, use it } else ...

Read More

With JavaScript Regular Expression find a non-whitespace character.

Daniol Thomas
Daniol Thomas
Updated on 15-Mar-2026 508 Views

To find a non-whitespace character in JavaScript regular expressions, use the \S metacharacter. This matches any character that is not a space, tab, newline, or other whitespace character. Syntax \S // Matches any non-whitespace character \S+ // Matches one or more non-whitespace characters \S* // Matches zero or more non-whitespace characters Example: Finding Non-Whitespace Characters JavaScript Regular Expression ...

Read More

How can I access document properties using Legacy DOM method in JavaScript?

Srinivas Gorla
Srinivas Gorla
Updated on 15-Mar-2026 249 Views

To access document properties using Legacy DOM methods in JavaScript, you can use various built-in properties and collections that provide information about the document structure and content. Common Legacy DOM Properties The Legacy DOM provides several properties to access document information: document.title - Gets the document title document.URL - Gets the complete URL document.forms - Collection of all forms document.images - Collection of all images document.links - Collection of all links Example Document Title ...

Read More

With JavaScript RegExp search a carriage return character.

Ayyan
Ayyan
Updated on 15-Mar-2026 757 Views

To find carriage return characters with JavaScript Regular Expression, use the \r metacharacter. This pattern matches the carriage return character (ASCII code 13) in strings. Syntax /\r/ Example: Finding Carriage Return Position The following example shows how to search for a carriage return character and return its position in the string: JavaScript Regular Expression ...

Read More

How objects are organized in a web document? How is it arranged in a hierarchy?

Anvi Jain
Anvi Jain
Updated on 15-Mar-2026 293 Views

The objects in a web document are organized in a hierarchical structure called the Document Object Model (DOM). This hierarchy represents the relationship between different elements and allows JavaScript to interact with web page components systematically. DOM Hierarchy Structure The DOM follows a tree-like structure where each object has a specific position and relationship with other objects: Window object − Top of the hierarchy. It represents the browser window and is the global object for all JavaScript operations. ...

Read More

What are the document methods supported by Legacy DOM?

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

The Legacy DOM provided several document methods for manipulating document content. While most are deprecated in modern web development, understanding them helps with legacy code maintenance. Legacy DOM Document Methods Method Description & Usage clear() Deprecated - Erased document contents and returned nothing. Example: document.clear() close() Closes a document stream opened with open() method. Example: document.close() open() Deletes existing content and opens a stream for new content. Example: document.open() write() Inserts strings into the document during parsing or after open(). Example: document.write("Hello World") ...

Read More
Showing 31–40 of 328 articles
« Prev 1 2 3 4 5 6 33 Next »
Advertisements