
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6710 Articles for Javascript

1K+ Views
The task we are going to perform in this article is setting a default variable value to undefined in a function. Before we jump into the article, let’s understand what are functions in JavaScript. One of the core components of JavaScript are functions. In JavaScript, a function is comparable to a procedure-a collection of statements that carry out an action or compute a value. However, in order for a process to be considered a function, it must accept an input and produce an output with an evident connection between the input and the result. Let’s see how to set a ... Read More

4K+ Views
Testing if a parameter is provided to a function in JavaScript is an important part of writing effective code. It allows you to ensure that the arguments passed into your functions are valid and properly formatted for use within the function. In this article, we will discuss different methods for testing whether or not a parameter has been provided to a function in JavaScript. Let us understand, the term “Parameter”. A parameter is a named entity in a function definition that specifies an argument which the function can accept. It acts as a variable within the function and its value ... Read More

907 Views
The task we are going to perform in this article is clear element classlist in JavaScript. Before we jump into the article let’s have a quick view on the few things. All element objects (i.e., objects that represent elements) in a Document derive from the most general base class is called Element. It only contains functions and characteristics that apply to all types of elements. Classlist in JavaScript JavaScript classList is a DOM attribute that enables customizing of an element's CSS (Cascading Style Sheet) classes. The read-only JavaScript classList property retrieves the names of the CSS classes. Syntax Following ... Read More

3K+ Views
In this article we are going to learn about how to insert space after every two letters in string. Before we jump into the article let’s have a quick view on the strings in JavaScript. A sequence of one or more characters—which could be numbers, or symbols—is referred to as a string. Strings are immutable primitive data types in JavaScript, which means they cannot be changed. Let’s dive into the article to learn more about inserting a space after every two letters in strings. For this, use replace() along with regular expressions. The replace() methodinJavaScript The replace() method ... Read More

1K+ Views
Multiple values can be kept in a single variable by using arrays. Compare that to a variable that only has room for one value. Each item in an array has a number associated with it that you may access by using, referred to as a numeric index. Arrays in JavaScript begin at index zero and can be changed using a variety of operations. The addEventListener()Method The addEventListener() is a method in JavaScript that allows an element to be assigned an event handler, which will execute when a specified event occurs. This can include things like mouse clicks, form submission, ... Read More

264 Views
The colon (:) can be used when you want to define the property to an object while equal (=) can be used when you want to assign a value to a variable.ExampleFollowing is the code −var studentDetails = { "studentId": 101, "studentName": "John", "studentSubjectName": "Javascript", "studentCountryName": "US" } console.log(studentDetails); var firstName = "David"; console.log(firstName);To run the above program, you need to use the below command −node fileName.js.Here, my file name is demo325.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo325.js { studentId: 101, studentName: 'John', studentSubjectName: 'Javascript', studentCountryName: 'US' } David

3K+ Views
If you are working with currency values in your web application, it is important to convert them from a string representation into an actual numerical value. In this article, we will discuss how to do this using both jQuery and JavaScript. We will look at the different methods available for converting strings to doubles. There are two popular ways to convert currency string into float string using different JavaScript inbuilt libraries. Let’s look into the following article to understand more about how to convert a currency string to a double with jQuery or JavaScript. This is a straightforward way in ... Read More

20K+ Views
In this article we are going to learn about detecting arrow key presses in JavaScript. Before we jump into the article, let’s discuss few things to know some information. There is a distinct key code for each key on the keyboard. Here, we'll check to see if the arrow key has been pressed. There are four arrow keys on our keyboard. On our keyboard, we can see, the left, right, up, and download keys. These keys also have a special key code that JavaScript can utilise to determine whether, or not they have been depressed. The key codes for the ... Read More

262 Views
To remove child elements, set the innerHTML to ‘’.ExampleFollowing is the code − Document Javascript MySQL Remove the items remove.onclick = () => { const element = document.getElementById("removeAllChildElements"); element.innerHTML = ''; } To run the above program, save the file name anyName.html(index.html). Right click on the file and select the option “Open with live server” in VS Code editor.OutputThis will produce the following output −Now you can click the button “Remove the items”. It will remove all the elements inside the box.OutputThis will produce the following output −

136 Views
Use the map() function correctly to save elements.ExampleFollowing is the code −const addIndexValueToArrayElement = function (arrObject) { const updatedArrayValue = []; arrObject.forEach(function (ob) { const mapValue = ob.map(function (value) { return value + arrObject.indexOf(ob) }) updatedArrayValue.push(mapValue) }) return updatedArrayValue; }; const output = addIndexValueToArrayElement([ [4, 5], [7, 56], [34, 78], ]); console.log(output);To run the above program, you need to use the below command −node fileName.js.Here, my file name is demo323.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo323.js [ [ 4, 5 ], [ 8, 57 ], [ 36, 80 ] ]