- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 6683 Articles for Javascript
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
2K+ Views
The most practical way to display datetime for efficient time analysis is in a 12 hour am/pm format. Additionally, this method clarifies the distinction between morning and evening. As an illustration, "am/pm" both specify a certain time period and make it simple to understand the time, which is not the case with the 24-hour format. This article will explain the ways of displaying JavaScript datetime in 12hour am/pm format. Displaying JavaScript datetime in 12hour am/pm format Let’s dive one by one to understand more about displaying JavaScript datetime in 12hoyur am/pm format. We can extract the hours and minutes from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
866 Views
You can use event listeners for clicks.ExampleFollowing is the code − Live Demo Document First Division Second Division document.addEventListener('click', callEventFuncion) function callEventFuncion(event) { var div = document.querySelectorAll('.divDemo'); var titleResult = document.querySelectorAll('.my-title'); var result = Array.apply(0, div).find((v) => v.contains(event.target)); if (result) { console.log(" Incrementing Division Selection"); } else { ... Read More
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
2K+ Views
In JavaScript Arrays are used to hold several values in a single variable. When opposed to a variable, which can hold only one value, this Each element of an array has a number associated with it called a numeric index that enables access to it. Arrays in JavaScript begin at index zero and can be modified using a number of different techniques. Let's take a look at the general case of sorting an array that contains undefined in JavaScript. The array is given below − var namearr = ["Zebra", "Yatch", undefined, "Egg", undefined]; For sorting the array that was ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
236 Views
For this, use join(). It will concatenate the string value length-1.ExampleFollowing is the code −var count = 5; var values = new Array(count + 1).join('John'); console.log(values); var count1 = 5; var values1 = new Array(count1).join('John'); console.log(values1);To run the above program, you need to use the following command −node fileName.js. Here, my file name is demo274.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo274.js JohnJohnJohnJohnJohn JohnJohnJohnJohn
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
3K+ Views
Before we are going to learn about how to get substring between two similar characters in JavaScript. Let’s have a quick view on the characters in JavaScript. In a string, the charAt() method returns the character that is located at the given index (position). First character's index is 0, second character's index is 1. Getting substring in JavaScript The substring() method takes a string and extracts all characters between two indices (positions), then it returns the substring. Characters are taken out of a string using the substring() technique. The initial string is left alone when using the substring() technique. Syntax ... Read More
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
1K+ Views
We will try to develop a method to change text with spaces and lowercase letters into text with underscores, where the initial letter of each word is capitalized. Let's examine the equation in its entirety. tutorials point = Tutorials_Point //expected output Let’s dive into article for getting better understanding on capitalize a word and replace spaces with underscore JavaScript. Using replace() method The replace() method looks up a value or regular expression in a string. A new string with the replaced value() is the result of the replace() method. The original string is unchanged by the replace() technique. Syntax ... Read More
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
936 Views
Characters that are neither alphabetical nor numeric are known as special characters. Special characters are essentially all unreadable characters, including punctuation, accent, and symbol marks. Remove any special characters from the string to make it easier to read and understand. We use replace() method to replace all the special characters following another character. Using replace() method The JavaScript built-in method string.replace() can be used to replace a portion of a supplied string with another string or a regular expression. The original string won't alter at all. Syntax Following is the syntax for replace() − string.replace(searchValue, newValue) Let’s look into ... Read More
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
5K+ Views
Scripting in JavaScript is simple, cross-platform, and lightweight. It is widely used in nonbrowser situations and is well known for web page building. Both client-side and serverside development can be done with JavaScript. JavaScript has built-in methods that can be used to generate random strings and modify the Document Object Model (DOM) in accordance with our needs. The random() function, which helps to generate the random index and multiple with the length of the string, will be accessed through the Math library. It will append the character from the string or character set as it is passed. Create ... Read More
![Yaswanth Varma](https://www.tutorialspoint.com/assets/profiles/511236/profile/60_1602256-1662106429.jpg)
504 Views
The task we are going to perform in this article is how to filter an array from all elements of another array JavaScript. Before we dive into the article, let’s have a quick view on the array in JavaScript. When storing multiple values in a single variable, arrays are used. When compared to a variable, which can hold only one value, this Each element of an array has a number associated with it called a numeric index that enables access to it. Arrays in JavaScript begin at index zero and can be modified using a number of different techniques. In ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
917 Views
With Spread Operator, allow the expression to expand to multiple arguments, elements, variables, etc.You can use JSON.stringify() to convert the JavaScript object to string. Here, we have our object as the result of using spread operator on details1 and details2.ExampleFollowing is the code −var details1 = { name: 'John', age: 21 }; var details2 = { countryName: 'US', subjectName:'JavaScript' }; var result= { ...details1, ...details2}; console.log(JSON.stringify(result));To run the above program, you need to use the following command −node fileName.js. Here, my file name is demo267.js.OutputThis will produce the following output on console −PS C:\Users\Amit\javascript-code> node demo267.js {"name":"John", "age":21, "countryName":"US", "subjectName":"JavaScript"}Read More