Home »
JavaScript
JavaScript Examples
JavaScript is a scripting or programming language that is used both on the client-side and server-side development, it is a high-level, often just-in-time compiled, and multi-paradigm language that allows you to make web pages interactive.
JavaScript Examples/Programs: This section contains JavaScript examples from basic concepts to advanced. Practice these examples to make a webpage interactive. Each example has the solved code, output, and explanation.
List of JavaScript Examples
- Input value from the user using prompt
- How to add float numbers using JavaScript?
- How to Round off a number to next multiple of 5 using JavaScript?
- Example of if with else
- Example of if else if
- Example of Nested if
- Find largest of three numbers using Nested if in JavaScript
- Example of Ternary Operator
- Image Recognition Game using JavaScript
- Code to input age and check person is eligible for voting or not
- Function with default value
- Function call example with given number of arguments and less arguments
- Demonstrate the example of call by value in function
- Some of the examples of user-defined functions
- Common properties and methods of Array
- Code to declare an array and assign the elements using array indexing
- Code to declare an array and print using for each loop
- Code to declare an array and print using for loop
- Password strength checker in JavaScript
- Print characters of a string in multiples of N in JavaScript
- How to check whether a string contains a substring in JavaScript?
- How to break in nested loops in JavaScript?
- Understanding callbacks in JavaScript
- How to create accordions with JavaScript?
- JavaScript code to check number is Perfect or not
- JavaScript code to check number is Armstrong or not
- JavaScript code to check whether a Number is Prime or Not
- JavaScript code to find largest of three numbers
- Check number is palindrome or not in JavaScript
- Form validation using JavaScript
- JavaScript code to design calculator
- Disable right click on webpage with JavaScript
- How to make the font bold using JavaScript?
- Return multiple elements from function in JavaScript
- How to get URL parameters using JavaScript?
- How to copy text to clipboard with JavaScript?
- How to get days of current month in JavaScript?
- Get browser details through JavaScript
- Calculate the average of arguments in JavaScript
- Ways to access object property in JavaScript
- Count occurrence of a particular character in a string in JavaScript
- Creating a property on prototype in JavaScript
- Create a student object and print the details in JavaScript
- Create a forward and back buttons in JavaScript
- Different ways to create an Object in JavaScript
- How to allow only alphabets in input field in JavaScript?
- Get the size of a file with JavaScript
- How to get the decimal part of a floating number in JavaScript?
- Get current date, month and year in JavaScript
- How to parse number from string in JavaScript?
- How to find absolute value of a number in JavaScript?
- Create functions with default arguments in JavaScript
- How to return object from function in JavaScript?
- Get index of an element in JavaScript
- Print a fibonacci series in JavaScript
- Find the larger of two numbers in JavaScript
- Convert a number into different base in JavaScript
- Find substring within a string in JavaScript
- Count the number of arguments passed to function in JavaScript
- Ways to create Date object in JavaScript
- Check if number is a valid number in JavaScript
- Determine the largest element in the array in JavaScript
- Addition of two numbers using JavaScript
- Create a user defined array in JavaScript
- Concatenation operator in JavaScript
- New variable declaration keywords in JavaScript
- Dynamically add CSS class with JavaScript
- Reverse an array in JavaScript
- Access global variables inside function in JavaScript
- How to fill dropdowns using JavaScript?
- Create a string parser with symbols for actions in JavaScript
- Join elements of an array in JavaScript
- JavaScript multiply every array element with a constant
- JavaScript check if an array element is empty
- Different ways to display output in JavaScript
- Check if an element is present in an Array in JavaScript?
- How to change the font-size with JavaScript?
- JavaScript Reverse print an array
- Template literals in JavaScript
- How to get the extension of a file using JavaScript?
- The JavaScript forEach method in detail
- Generate random number within a range in JavaScript
- JavaScript program to create an object from a function
- JavaScript program to split the keywords in the string
- JavaScript program to check if the variable is a valid string variable
- JavaScript Program to print sum of range with steps
- JavaScript Program to create a power function and print the result
- JavaScript to detect whether page is load on Mobile or Desktop
- JavaScript - Select/Unselect (Check/Uncheck) all CheckBoxes on Button Click
- JavaScript - Allow only numbers in TextBox (Restrict Alphabets and Special Characters)
- JavaScript - Redirect to another URL on Button Click
- JavaScript - Display Input Text into Lowercase
- JavaScript - Display Input Text into Uppercase
- JavaScript - Display current Date and Time
- Check selected Radio Button value using JavaScript
- JavaScript function to add two integer numbers
- Show/Hide Div on Button Click using JavaScript
- Display different Alert Message on different Button Click Event using JavaScript
- Display Alert Message on Button Click Event using JavaScript
- JavaScript - Print value of all checked (selected) CheckBoxes on Button click
- JavaScript - Print Selected Item from SelectBox
- JavaScript - Add user entered item into ListBox
- JavaScript - Required Field Validator for TextBox on Submit
- JavaScript - Move Object with Arrow Keys using JavaScript Function
- JavaScript - Set Focus on Particular Field in a Form using JavaScript Function
- JavaScript - Set Customize Text in Browser Status Bar using JavaScript Function
- JavaScript - Detect and Display Screen Resolution using JavaScript Function
- JavaScript - Function to Refresh Page on Button Click
- JavaScript - Function to Display Table of an entered Number
- JavaScript - Disable Button after Click using JavaScript Function
- JavaScript - Close Current Tab on Button Click with Confirmation
- JavaScript - Show/Hide Paragraph Text inside Div on Button Click
- Simple Web Dictionary | JavaScript Switch Statement Project
- Data Unit Conversion Tool in JavaScript
- Age calculator Web Application | Integrating JavaScript function with form
- Lowercase to Uppercase Converter JavaScript Tool | Web App Project
- Sample report card web application prototype using JavaScript
- JavaScript | Create an object and display its values in a table
- JavaScript | Create an object and display its content in a table through JavaScript function
- JavaScript | Create an object by passing values in the function and display in the table
- Capitalize words in a string in JavaScript
- How to get multiple random unique elements from an array in JavaScript?
- JavaScript - How to get a key in an object by its value?
- JavaScript - How to get the first key name of a JavaScript Object?
- JavaScript - How to check if a key exists in a JavaScript Object?
- JavaScript - How to iterate over a JavaScript Object?
- How to access an object having spaces in the object's key using JavaScript?
- How to check if an array includes an object in JavaScript?
- Convert an array to an object in JavaScript
- How to check if a JavaScript object is a DOM object?
- How to check object is an array in JavaScript?
- Search from Array of Objects | JavaScript
- How to replace element from an array in JavaScript?
- Web Application: A To-do List using JavaScript
- How to add a class name to an element in JavaScript?
- How to change the src of an element in JavaScript?
- How to change the class of an element in JavaScript?
- How to create hash from string in JavaScript?
- How to remove CSS property using JavaScript?
- How to round Off a number upto 2 decimal places using JavaScript?
- How to return a value from a JS asynchronous callback function?
- How to compare two JavaScript array objects using JavaScript?
- Method to show or hide elements in HTML using display property in JavaScript
- Get current time in Hours24: Minutes: Seconds format in JavaScript
- Get current Date in Date / Month / Year format in JavaScript
- Get current UTC time in Hours24: Minutes: Seconds format in JavaScript
- Get current UTC Date in Date / Month / Year format in JavaScript
- Retrieve the position (XY) of an HTML element
- Dynamically Populating drop-down list from selection another drop-down value
- How can I merge properties of two JavaScript objects dynamically?
- Length of a JavaScript object
- JavaScript: How to append something to an array?
- Is there a standard function to check for null, undefined, or blank variables in JavaScript?
- How to replace all occurrences of a string in JavaScript?
- How do I check if an array includes a value in JavaScript?
- How do you get a timestamp in JavaScript?
- Which 'href' value should I use for JavaScript links, '#' or 'javascript:void(0)'?
- What is the !! (not not) operator in JavaScript?
- What does 'use strict' do in JavaScript, and what is the reasoning behind it?
- What is the most efficient way to deep clone an object in JavaScript?
- How do I remove a property from a JavaScript object?
- Check whether a string contains a substring using includes() and indexOf() methods in JavaScript
- How can I remove a specific item from an array in JavaScript?
- var functionName = function() {} vs function functionName() {}
- What's the difference between using 'let' and 'var'?
- Which equals operator (== vs ===) should be used in JavaScript comparisons?
- Check if a variable is a string in JavaScript
- Can (a== 1 && a ==2 && a==3) ever evaluate to true?
- Open a URL in a new tab (and not a new window)
- Compare two dates with JavaScript
- Set a default parameter value for a JavaScript function
- Validate decimal numbers in JavaScript - IsNumeric()
- How can I determine if a variable is 'undefined' or 'null'?
- Generate random string/characters in JavaScript
- How to check if element is visible after scrolling?
- Get all unique values in a JavaScript array (remove duplicates)
- JavaScript equivalent to printf/String.Format
- How to find the sum of an array of numbers?