Object Oriented Programming Articles

Page 96 of 589

JavaScript Numbers example

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 197 Views

JavaScript has a single number type that represents both integers and floating-point numbers. Unlike other languages, JavaScript doesn't distinguish between different numeric types. Number Types in JavaScript All numbers in JavaScript are stored as 64-bit floating-point values, following the IEEE 754 standard. This means you can work with both whole numbers and decimals seamlessly. JavaScript Numbers body { ...

Read More

JavaScript Promises

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 1K+ Views

Promises in JavaScript allow us to handle asynchronous operations where the value is not known in advance when the promise is being created. A promise can have three states: pending, fulfilled, and rejected. Promise States A promise represents an asynchronous operation and can be in one of three states: Pending: Initial state, neither fulfilled nor rejected Fulfilled: The operation completed successfully Rejected: The operation failed Creating a Basic Promise Here's how to create a simple promise: ...

Read More

JavaScript undefined Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 248 Views

The JavaScript undefined property represents a value that indicates a variable has been declared but not assigned a value, or a property that doesn't exist. What is undefined? undefined is a primitive value automatically assigned to variables that are declared but not initialized, and to object properties that don't exist. Common Cases Where undefined Occurs // Declared but not assigned let age; console.log(age); // undefined // Function with no return value function greet() { console.log("Hello"); } let result = greet(); console.log(result); // undefined // Accessing non-existent object property let ...

Read More

JavaScript unescape() with example

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 305 Views

The JavaScript unescape() function is used to decode strings that were encoded with the escape() function. This function is deprecated since JavaScript 1.5 and should not be used in modern code. Use decodeURIComponent() instead. Syntax unescape(encodedString) Parameter: encodedString - The string to be decoded. Return Value: A new decoded string. Example with unescape() (Deprecated) JavaScript unescape() Example body { ...

Read More

JavaScript WebAPI File File.name Property

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 143 Views

The JavaScript File WebAPI file.name property returns only the name of the file without the path. This property is read-only and provides access to the filename when working with file inputs or drag-and-drop operations. Syntax file.name Return Value Returns a string containing the name of the file without any path information. The name includes the file extension if present. Example File.name Property Example ...

Read More

JavaScript to generate random hex codes of color

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 345 Views

Generating random hex color codes in JavaScript involves creating a 6-character string from hexadecimal digits (0-9, A-F) and prefixing it with '#'. This is useful for creating dynamic color schemes, themes, or visual effects. Understanding Hex Color Codes Hex color codes use the format #RRGGBB where each pair represents red, green, and blue values in hexadecimal (0-F). For example, #FF0000 is pure red, #00FF00 is green, and #0000FF is blue. Method 1: Using Math.random() with Character Selection Random Hex Color Generator ...

Read More

JavaScript Importing and Exporting Modules

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 350 Views

JavaScript modules allow you to split code into separate files and share functionality between them using import and export statements. This promotes code reusability and better organization. Note: To run module examples, you need a localhost server since modules use CORS policy. Export Types There are two main ways to export from a module: Default Export: One main export per module Named Export: Multiple exports with specific names Default Export Example math.js (module file): // Default export - only one per module export default function add(a, b) { ...

Read More

How to create a countdown timer with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 746 Views

A countdown timer in JavaScript uses setInterval() to update the display every second by calculating the time difference between a target date and the current time. How It Works The countdown timer works by: Setting a target date in the future Calculating the time difference every second Converting milliseconds to days, hours, minutes, and seconds Updating the display and stopping when time expires Complete Example body { ...

Read More

How to create a typing effect with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 347 Views

To create a typing effect with JavaScript, you can simulate the appearance of text being typed character by character. This effect is commonly used for animated headers, loading messages, or interactive demonstrations. Basic Typing Effect Here's a complete example that demonstrates how to create a typing effect: body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 20px; } button { padding: 10px 20px; ...

Read More

How to close list items with JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 655 Views

Closing list items with JavaScript involves adding click event listeners to close buttons that hide or remove list items from the DOM. This creates an interactive list where users can dismiss items they no longer need. Complete Example body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } * { ...

Read More
Showing 951–960 of 5,881 articles
« Prev 1 94 95 96 97 98 589 Next »
Advertisements