- 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 6685 Articles for Javascript
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
9K+ Views
In JavaScript, sometimes, we are required to use the variables as an object key. For example, when fetching data from the API and not sure about all the response data attributes, we must iterate through the response object and store every property of it. However, we can’t use the variables as a key while creating the object, but after creating, we can add the variable properties to the object. Syntax Users can follow the syntax below to use a variable for a key in a JavaScript object. object[key] = value; In the above syntax, ‘key’ is a variable containing ... Read More
![Mr. Satyabrata](https://www.tutorialspoint.com/assets/profiles/526132/profile/60_3653035-1664258182.jpeg)
1K+ Views
Java and JavaScript are two programming languages that are often compared and pitted against each other, thanks to their similar names. However, they are fundamentally different languages, with their own unique strengths and applications. Java is a mature language that has been around for over two decades and is widely used for enterprise-level software development. It is known for its stability, security, and cross-platform compatibility. Java's static type checking system makes it a safer option for larger software projects. On the other hand, JavaScript is a dynamic language that is primarily used for front-end web development. It enables developers to ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
451 Views
In JavaScript, an object contains the properties in the key-value format. We can access any property of an object using the property name by taking the object as a reference. Sometimes, we try to access the object property that doesn’t exist in the object. In such cases, we get the undefined value. Let’s understand it by the example below. Example (Accessing the Object Properties) In the example below, we have created the object and added some properties. Also, we have added some nested properties. After that, we try to access the ‘prop5’ property which is a nested property of the ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
1K+ Views
The code often throws an error, and handling errors is more important. JavaScript also allows users to throw a custom error using the ‘throw’ keyword. We can catch the errors in the catch block. We can use the try-catch syntax to catch errors thrown by normal functions. Let’s understand it by the example below. Example 1 (Throw Errors in Regular Function) In the example below, we have created the throwError() regular function, which uses the throw keyword to throw an error with the custom error message. We have executed the function inside the try block. If the function throws any ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
7K+ Views
Whenever you develop a website or application for a worldwide business, you must also focus on which language your audience can understand. For example, English is an international language, but in some parts of the world, people don’t understand English as they speak German, Spanish etc. However, if you have observed, then some websites provide the option to change the website's language. You just need to click on the button, which changes the whole website's language. Have you ever thought about how it is possible? Here, we will learn to switch the language of the web page using JavaScript. Syntax ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
518 Views
Sometimes, developers may require to store the function in the queue and execute it in the order it is stored in the queue. In JavaScript, we can create a queue using the array. We can use the push() method of the array to enqueue the function in the queue and the shift() method to deque the function from the queue. Below, we will see examples of storing JavaScript functions in the queue and executing them in the queue order. Syntax Users can follow the syntax below to store JavaScript functions in a queue and execute in that order. while (queue.length ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
1K+ Views
Storing data in the DOM means storing data in plain text format. For example, we store data in the state variable while using React or any other reactive framework. When the user updates the data in the input field, it stores updated data in the state variable. So, we store data in the state variable before we submit the form. At the time of submitting the form, we use the values of the state variables. In vanilla JavaScript, we can do the same, like storing data in plain text format, and whenever we require to submit the form, we can ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
602 Views
In some text editors, when you select the text, it shows the menu to edit texts and provides functionalities like justifying text, aligning text, increasing the text size, changing colour, etc. Microsoft word is the best example of it. In Microsoft word, when you select any text, it shows the custom horizontal menu to perform some actions on the text. This tutorial will use JavaScript to create a custom menu on the text selection. Syntax Users can follow the syntax below to show some custom menu on text selection. let coOrdinates = document.querySelector(".content").getBoundingClientRect(); let posX = clientX - Math.round(coOrdinates.left) + ... Read More
![Biswaindu Parida](https://www.tutorialspoint.com/assets/profiles/630963/profile/60_1947439-1680157237.jpg)
162 Views
Overview to Java Optimization Java is a popular programming language for developing mobile apps to enterprise-level software systems. However, as the size and complexity of Java applications increase, so does the potential for performance issues. Java optimization identifies and addresses performance bottlenecks in Java applications to ensure they run efficiently and meet the desired performance requirements. In this article, we will explore the importance of Java optimization and provide an overview of key techniques and best practices for optimizing Java code. We will also discuss common performance issues, how to address them, and the tools and resources available to ... Read More
![Prabhdeep Singh](https://www.tutorialspoint.com/assets/profiles/546958/profile/60_1428686-1667456005.jpg)
183 Views
To find the maximum or minimum element, we have to focus on the number of comparisons we are going to make and which method will be efficient to choose for comparisons: the one that compares elements with if-else statements or one which comes as in-built. We will see the complete code implementation with the explanation. In this article, we are going to implement a JavaScript program for the maximum and minimum elements present in a given square matrix. Introduction to Problem This problem is very simple, but then going into deep will bring some good highlighted concepts that are worth ... Read More