Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Front End Technology Articles
Page 345 of 652
How to set current time to some other time in JavaScript?
You cannot directly modify the system time with JavaScript since it uses the system's clock through the Date object. However, you can simulate different times by adjusting timezones or creating custom date objects with specific values. Method 1: Using Timezone Conversion You can display time for different timezones by calculating the offset from UTC: var date, utc, offset, singaporeTime; date = new Date(); ...
Read MoreHow to manipulate JavaScript's Date object?
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 MoreWhat is the difference between custom and built-in functions in JavaScript?
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 MoreHow to invoke a JavaScript Function as a method?
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 MoreHow can we assign a function to a variable in JavaScript?
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 MoreHow can we use a JavaScript function as an object?
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 MoreHow to define custom JavaScript exceptions?
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 MoreHow to catch any JavaScript exception in Clojurescript?
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 MoreWhat are common HTML Events supported by JavaScript?
JavaScript supports numerous HTML events that allow you to create interactive web pages. These events are triggered by user actions like clicks, keyboard input, or changes to HTML elements. Mouse Events Mouse events are the most commonly used events for creating interactive interfaces: Event Description ...
Read MoreHow to name JavaScript Identifiers?
In this tutorial, we will learn how to name JavaScript Identifiers. Identifiers in JavaScript are the names we give to variables, arrays, objects, functions, etc. We must give them unique names to identify them properly. There are specific rules we must follow when naming identifiers that are common to most programming languages. Rules for Naming Identifiers There are certain rules we have to follow before naming an identifier. A proper name helps the programmer to make the code more effective. The rules are the following: JavaScript identifier names should not start with ...
Read More