Javascript Articles

Page 304 of 534

How to manipulate JavaScript's Date object?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 3K+ Views

JavaScript's Date object provides powerful methods to manipulate dates and times. You can use getter methods to retrieve date components and setter methods to modify them. Understanding these methods is essential for effective date manipulation in JavaScript applications. Once a Date object is created, numerous methods allow you to operate on it. Most methods let you get and set the year, month, day, hour, minute, second, and millisecond fields using either local time or UTC (universal, or GMT) time. Common Date Methods Here are the key methods used with Date objects: Sr.No Methods ...

Read More

What is the difference between custom and built-in functions in JavaScript?

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

JavaScript functions are divided into two main categories: custom (user-defined) functions and built-in functions. Understanding the difference helps you leverage JavaScript's capabilities effectively. Custom Functions (User-Defined) Custom functions are created by developers to perform specific tasks. You define the logic, parameters, and return values according to your needs. Syntax function functionName(parameter1, parameter2) { // Your custom logic here return result; } Example: Custom Function Custom Function Example ...

Read More

Set the top margin of an element with CSS

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 122 Views

The margin-top property specifies the top margin of an element in CSS. It creates space above an element, pushing it away from adjacent elements or the container's top edge. Syntax margin-top: value; The value can be specified in pixels (px), percentages (%), em units, or set to auto for automatic margin calculation. Example CSS margin-top Example This ...

Read More

How to invoke a JavaScript Function as a method?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

In this tutorial, we will learn how to invoke a JavaScript Function as a method. In JavaScript, the code inside a function will execute when the function is invoked. We can invoke a function in a variety of ways. One of them is using the method. The method is a property of an object that has a function value. We can define functions as object methods. This function will have a function name, a parameter (optional), and a return type (optional). It will have a "this" keyword which refers to an object. Users can follow the syntax below ...

Read More

How can we assign a function to a variable in JavaScript?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 27K+ Views

In this tutorial, we will learn to assign a function to a variable in JavaScript. Functions are reusable code blocks that can be stored in variables as expressions. There are two main ways to achieve this: using anonymous functions and arrow functions. Most JavaScript programmers are familiar with named functions, which follow this syntax: function function_name() { // function body } However, when we want to assign a function to a variable as an expression, we have two different approaches: Creating Anonymous Functions ...

Read More

Usage of margin-bottom property with CSS

Lakshmi Srinivas
Lakshmi Srinivas
Updated on 15-Mar-2026 86 Views

The margin-bottom CSS property specifies the bottom margin of an element, creating space below it. It accepts values in pixels, percentages, ems, or the keyword auto. Syntax margin-bottom: length | percentage | auto | initial | inherit; Parameters length - Fixed value in px, em, rem, etc. percentage - Relative to parent element's width auto - Browser calculates the margin automatically initial - Sets to default value (0) inherit - Inherits from parent element Example: Basic margin-bottom Usage ...

Read More

How can we use a JavaScript function as an object?

Shubham Vora
Shubham Vora
Updated on 15-Mar-2026 2K+ Views

This tutorial will teach us to use JavaScript functions as objects. In JavaScript, functions are first-class objects, meaning they can have properties and methods just like regular objects. This powerful feature allows us to create constructor functions that act as blueprints for creating multiple similar objects. The JavaScript object is an entity that contains key-value pairs with unique keys. Each key has values that can be of any type. We can access object values using their keys. We can create a function that behaves like an object using the this keyword and the new operator. Below is a ...

Read More

How to define custom JavaScript exceptions?

V Jyothi
V Jyothi
Updated on 15-Mar-2026 238 Views

Custom JavaScript exceptions allow you to create specific error types for your application. You can throw custom error messages or create custom error classes for better error handling. Basic Custom Exception with String The simplest way to create a custom exception is by throwing a string message: function divide(a, b) { try { ...

Read More

How to set the bottom margin of an element?

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

The margin-bottom property sets the bottom margin of an element, creating space between the element and content below it. It accepts values in pixels, percentages, or auto. Syntax element.style.marginBottom = "value"; Parameters The margin-bottom property accepts the following values: Length: Pixels (px), em, rem, etc. Percentage: Relative to parent element's width auto: Browser calculates the margin automatically Example: Setting Bottom Margin with CSS .large-margin { ...

Read More

How to catch any JavaScript exception in Clojurescript?

Sravani Alamanda
Sravani Alamanda
Updated on 15-Mar-2026 288 Views

ClojureScript is a dialect of the Clojure programming language that compiles to JavaScript, allowing developers to use Clojure's functional programming paradigms in web browsers and Node.js environments. When building ClojureScript applications, proper exception handling is crucial for maintaining application stability and user experience. What is ClojureScript? ClojureScript is a compiler that transforms Clojure code into optimized JavaScript. Originally, Clojure only compiled to Java Virtual Machine bytecode, but ClojureScript emerged in 2011 to bring Clojure's powerful features to client-side development. ClojureScript operates at a higher abstraction level than JavaScript. While JavaScript deals with variables, loops, conditions, and objects, ...

Read More
Showing 3031–3040 of 5,340 articles
« Prev 1 302 303 304 305 306 534 Next »
Advertisements