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

  1. Input value from the user using prompt
  2. How to add float numbers using JavaScript?
  3. How to Round off a number to next multiple of 5 using JavaScript?
  4. Example of if with else
  5. Example of if else if
  6. Example of Nested if
  7. Find largest of three numbers using Nested if in JavaScript
  8. Example of Ternary Operator
  9. Image Recognition Game using JavaScript
  10. Code to input age and check person is eligible for voting or not
  11. Function with default value
  12. Function call example with given number of arguments and less arguments
  13. Demonstrate the example of call by value in function
  14. Some of the examples of user-defined functions
  15. Common properties and methods of Array
  16. Code to declare an array and assign the elements using array indexing
  17. Code to declare an array and print using for each loop
  18. Code to declare an array and print using for loop
  19. Password strength checker in JavaScript
  20. Print characters of a string in multiples of N in JavaScript
  21. How to check whether a string contains a substring in JavaScript?
  22. How to break in nested loops in JavaScript?
  23. Understanding callbacks in JavaScript
  24. How to create accordions with JavaScript?
  25. JavaScript code to check number is Perfect or not
  26. JavaScript code to check number is Armstrong or not
  27. JavaScript code to check whether a Number is Prime or Not
  28. JavaScript code to find largest of three numbers
  29. Check number is palindrome or not in JavaScript
  30. Form validation using JavaScript
  31. JavaScript code to design calculator
  32. Disable right click on webpage with JavaScript
  33. How to make the font bold using JavaScript?
  34. Return multiple elements from function in JavaScript
  35. How to get URL parameters using JavaScript?
  36. How to copy text to clipboard with JavaScript?
  37. How to get days of current month in JavaScript?
  38. Get browser details through JavaScript
  39. Calculate the average of arguments in JavaScript
  40. Ways to access object property in JavaScript
  41. Count occurrence of a particular character in a string in JavaScript
  42. Creating a property on prototype in JavaScript
  43. Create a student object and print the details in JavaScript
  44. Create a forward and back buttons in JavaScript
  45. Different ways to create an Object in JavaScript
  46. How to allow only alphabets in input field in JavaScript?
  47. Get the size of a file with JavaScript
  48. How to get the decimal part of a floating number in JavaScript?
  49. Get current date, month and year in JavaScript
  50. How to parse number from string in JavaScript?
  51. How to find absolute value of a number in JavaScript?
  52. Create functions with default arguments in JavaScript
  53. How to return object from function in JavaScript?
  54. Get index of an element in JavaScript
  55. Print a fibonacci series in JavaScript
  56. Find the larger of two numbers in JavaScript
  57. Convert a number into different base in JavaScript
  58. Find substring within a string in JavaScript
  59. Count the number of arguments passed to function in JavaScript
  60. Ways to create Date object in JavaScript
  61. Check if number is a valid number in JavaScript
  62. Determine the largest element in the array in JavaScript
  63. Addition of two numbers using JavaScript
  64. Create a user defined array in JavaScript
  65. Concatenation operator in JavaScript
  66. New variable declaration keywords in JavaScript
  67. Dynamically add CSS class with JavaScript
  68. Reverse an array in JavaScript
  69. Access global variables inside function in JavaScript
  70. How to fill dropdowns using JavaScript?
  71. Create a string parser with symbols for actions in JavaScript
  72. Join elements of an array in JavaScript
  73. JavaScript multiply every array element with a constant
  74. JavaScript check if an array element is empty
  75. Different ways to display output in JavaScript
  76. Check if an element is present in an Array in JavaScript?
  77. How to change the font-size with JavaScript?
  78. JavaScript Reverse print an array
  79. Template literals in JavaScript
  80. How to get the extension of a file using JavaScript?
  81. The JavaScript forEach method in detail
  82. Generate random number within a range in JavaScript
  83. JavaScript program to create an object from a function
  84. JavaScript program to split the keywords in the string
  85. JavaScript program to check if the variable is a valid string variable
  86. JavaScript Program to print sum of range with steps
  87. JavaScript Program to create a power function and print the result
  88. JavaScript to detect whether page is load on Mobile or Desktop
  89. JavaScript - Select/Unselect (Check/Uncheck) all CheckBoxes on Button Click
  90. JavaScript - Allow only numbers in TextBox (Restrict Alphabets and Special Characters)
  91. JavaScript - Redirect to another URL on Button Click
  92. JavaScript - Display Input Text into Lowercase
  93. JavaScript - Display Input Text into Uppercase
  94. JavaScript - Display current Date and Time
  95. Check selected Radio Button value using JavaScript
  96. JavaScript function to add two integer numbers
  97. Show/Hide Div on Button Click using JavaScript
  98. Display different Alert Message on different Button Click Event using JavaScript
  99. Display Alert Message on Button Click Event using JavaScript
  100. JavaScript - Print value of all checked (selected) CheckBoxes on Button click
  101. JavaScript - Print Selected Item from SelectBox
  102. JavaScript - Add user entered item into ListBox
  103. JavaScript - Required Field Validator for TextBox on Submit
  104. JavaScript - Move Object with Arrow Keys using JavaScript Function
  105. JavaScript - Set Focus on Particular Field in a Form using JavaScript Function
  106. JavaScript - Set Customize Text in Browser Status Bar using JavaScript Function
  107. JavaScript - Detect and Display Screen Resolution using JavaScript Function
  108. JavaScript - Function to Refresh Page on Button Click
  109. JavaScript - Function to Display Table of an entered Number
  110. JavaScript - Disable Button after Click using JavaScript Function
  111. JavaScript - Close Current Tab on Button Click with Confirmation
  112. JavaScript - Show/Hide Paragraph Text inside Div on Button Click
  113. Simple Web Dictionary | JavaScript Switch Statement Project
  114. Data Unit Conversion Tool in JavaScript
  115. Age calculator Web Application | Integrating JavaScript function with form
  116. Lowercase to Uppercase Converter JavaScript Tool | Web App Project
  117. Sample report card web application prototype using JavaScript
  118. JavaScript | Create an object and display its values in a table
  119. JavaScript | Create an object and display its content in a table through JavaScript function
  120. JavaScript | Create an object by passing values in the function and display in the table
  121. Capitalize words in a string in JavaScript
  122. How to get multiple random unique elements from an array in JavaScript?
  123. JavaScript - How to get a key in an object by its value?
  124. JavaScript - How to get the first key name of a JavaScript Object?
  125. JavaScript - How to check if a key exists in a JavaScript Object?
  126. JavaScript - How to iterate over a JavaScript Object?
  127. How to access an object having spaces in the object's key using JavaScript?
  128. How to check if an array includes an object in JavaScript?
  129. Convert an array to an object in JavaScript
  130. How to check if a JavaScript object is a DOM object?
  131. How to check object is an array in JavaScript?
  132. Search from Array of Objects | JavaScript
  133. How to replace element from an array in JavaScript?
  134. Web Application: A To-do List using JavaScript
  135. How to add a class name to an element in JavaScript?
  136. How to change the src of an element in JavaScript?
  137. How to change the class of an element in JavaScript?
  138. How to create hash from string in JavaScript?
  139. How to remove CSS property using JavaScript?
  140. How to round Off a number upto 2 decimal places using JavaScript?
  141. How to return a value from a JS asynchronous callback function?
  142. How to compare two JavaScript array objects using JavaScript?
  143. Method to show or hide elements in HTML using display property in JavaScript
  144. Get current time in Hours24: Minutes: Seconds format in JavaScript
  145. Get current Date in Date / Month / Year format in JavaScript
  146. Get current UTC time in Hours24: Minutes: Seconds format in JavaScript
  147. Get current UTC Date in Date / Month / Year format in JavaScript
  148. Retrieve the position (XY) of an HTML element
  149. Dynamically Populating drop-down list from selection another drop-down value
  150. How can I merge properties of two JavaScript objects dynamically?
  151. Length of a JavaScript object
  152. JavaScript: How to append something to an array?
  153. Is there a standard function to check for null, undefined, or blank variables in JavaScript?
  154. How to replace all occurrences of a string in JavaScript?
  155. How do I check if an array includes a value in JavaScript?
  156. How do you get a timestamp in JavaScript?
  157. Which 'href' value should I use for JavaScript links, '#' or 'javascript:void(0)'?
  158. What is the !! (not not) operator in JavaScript?
  159. What does 'use strict' do in JavaScript, and what is the reasoning behind it?
  160. What is the most efficient way to deep clone an object in JavaScript?
  161. How do I remove a property from a JavaScript object?
  162. Check whether a string contains a substring using includes() and indexOf() methods in JavaScript
  163. How can I remove a specific item from an array in JavaScript?
  164. var functionName = function() {} vs function functionName() {}
  165. What's the difference between using 'let' and 'var'?
  166. Which equals operator (== vs ===) should be used in JavaScript comparisons?
  167. Check if a variable is a string in JavaScript
  168. Can (a== 1 && a ==2 && a==3) ever evaluate to true?
  169. Open a URL in a new tab (and not a new window)
  170. Compare two dates with JavaScript
  171. Set a default parameter value for a JavaScript function
  172. Validate decimal numbers in JavaScript - IsNumeric()
  173. How can I determine if a variable is 'undefined' or 'null'?
  174. Generate random string/characters in JavaScript
  175. How to check if element is visible after scrolling?
  176. Get all unique values in a JavaScript array (remove duplicates)
  177. JavaScript equivalent to printf/String.Format
  178. How to find the sum of an array of numbers?

Comments and Discussions!


Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.