Found 10483 Articles for Web Development

Where can I find documentation on formatting a date in JavaScript?

Krantik Chavan
Updated on 23-Jun-2020 06:50:58

106 Views

The Date object is a datatype built into the JavaScript language. Date objects are created with the new Date( ) as shown below −new Date( ) new Date(milliseconds) new Date(datestring) new Date(year, month, date[, hour, minute, second, millisecond ])The following method is used to Manipulate Dates in JavaScript −Sr.NoMethod & Description1Date()Returns today's date and time2getDate()Returns the day of the month for the specified date according to local time.3getDay()Returns the day of the week for the specified date according to local time.4getFullYear()Returns the year of the specified date according to local time.5getHours()Returns the hour in the specified date according to local ... Read More

How do you launch the JavaScript debugger in Google Chrome?

Abhinaya
Updated on 23-Jun-2020 06:40:20

287 Views

To launch JavaScript debugger in Google Chrome, try any of the following ways,Press Ctrl + Shift + JGo to Settings and click More Tools. After that, click Developer Tools.For more, refer the official website of  Chrome Dev Tool,

How to execute a JavaScript function using its name in a variable?

Shubham Vora
Updated on 23-Aug-2022 09:15:40

554 Views

What is a function in JavaScript? The JavaScript equivalent of a process is a function. A process is a series of instructions for carrying out a task or calculating a value. However, a process must accept input and produce a result to be considered a function. Additionally, there should be a clear connection between the input and the output. Follow the syntax below to define a function This tutorial will guide you to learn the way to execute a JavaScript function using its name in a variable. Syntax function functionName( param1, param2, param3 ) { //code } ... Read More

What are JavaScript Identifiers?

Smita Kapse
Updated on 23-Jun-2020 06:44:09

5K+ Views

JavaScript Identifiers are names given to variables, functions, etc. It is the same as identifiers in other programming languages like C, C++, Java, etc. Let’s see identifiers for variable names.The following are legal variable names −val val1 resultWhile naming your variables in JavaScript, keep the following rules in mind.You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.JavaScript variable names should not start with a numeral (0-9). They must begin with a letter or an underscore character. For ... Read More

How to use comments to prevent JavaScript Execution?

Ankitha Reddy
Updated on 30-Jul-2019 22:30:21

299 Views

If you want another code while working in the same code document, then use comments. Comment the previous code and add the alternative code to test it. After the testing completes, uncomment the previous code. In this way, you can test both the codes. While using comments follow the below rules to create valid comments − Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript. Any text between the characters /* and */ is treated as a comment. This may span multiple lines. JavaScript also recognizes the ... Read More

How much should be a JavaScript Line Length?

Nitya Raut
Updated on 17-Jan-2020 09:59:56

770 Views

Try to keep the length of lines less than 80 characters. This would make the code easier to read. Best practice is to move to next line using break if JavaScript statements aren’t fitting in a single line.In addition, move to next line only after a comma or operator. For example, you can add statement like this, with a break after operator,function display() {    var a = "";    a = a + isNaN(6234) + ": 6234";        a = a + isNaN(-52.1) + ": -52.1";    a = a + isNaN('') + ": ''";    document.getElementById("test").innerHTML = a; }

How to name JavaScript Identifiers?

Shubham Vora
Updated on 12-Oct-2022 08:57:42

2K+ Views

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 the names unique to identify them properly. There are some rules we must follow to name the identifiers that are common to most 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 any numeric values like 0-9. For ... Read More

What are common HTML Events supported by JavaScript?

Jennifer Nicholas
Updated on 23-Jun-2020 06:45:25

177 Views

The following are some of the common HTML events supported by JavaScript −AttributeValueDescriptiononclickscriptTriggers on a mouse clickoncontextmenuscriptTriggers when a context menu is triggeredondblclickscriptTriggers on a mouse double-clickondragscriptTriggers when an element is draggedondragendscriptTriggers at the end of a drag operationondragenterscriptTriggers when an element has been dragged to a valid drop targetondragleavescriptTriggers when an element is being dragged over a valid drop targetondragoverscriptTriggers at the start of a drag operationondragstartscriptTriggers at the start of a drag operationondropscriptTriggers when dragged element is being droppedondurationchangescriptTriggers when the length of the media is changed

How to pass an object as a parameter in JavaScript function?

Shubham Vora
Updated on 13-Sep-2023 15:33:27

34K+ Views

In this tutorial, we will learn how to pass an object as a parameter in a JavaScript function. One of JavaScript's data types is represented by the Object type. It is used to store keyed collections as well as more complex entities. The Object() function Object()or the object initializer / literal syntax can be used to create objects. Almost all JavaScript objects are instances of Object; a typical object inherits properties (including methods) from Object.prototype, though these properties may be shadowed (a.k.a. overridden). Following are the methods used to pass an object as a parameter in a JavaScript function. Using the ... Read More

How to catch any JavaScript exception in Clojurescript?

Sravani Alamanda
Updated on 08-Dec-2022 10:23:09

221 Views

In our code, usually, we will get an issue with errors. Errors will disturb the normal flow of our application. So, it is required to handle error exceptions in our code to implement any application in any programming language. Now, we will see how to handle exceptions in Clojurescript. Before that, first we learn what Clojurescript is. What is ClojureScript? At the fundamental level, Closurescript is an accent of the closure programming language that is used to compile to JavaScript. Actually, closure originally compiled only to Java virtual machine bytecode, later in 2011 Closurescript came as an option to ... Read More

Advertisements