JavaScript Programming Examples Last Updated : 25 Sep, 2025 Comments Improve Suggest changes Like Article Like Report JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.Used both on the client-side and server-side, making it versatile for full-stack development.Supports a wide range of frameworks and libraries like React, Angular, and Node.js.Plays a key role in creating modern, responsive, and interactive web applications.ES6This section features essential ES6 JavaScript programming examples. Whether you’re just starting or have mastered JavaScript, these examples provide a solid foundation for mastering modern JavaScript features.Check for Approximately EqualDeclare variables in different ways Replacing multiple object KeysFirst non-null/undefined argumentShorthand for Object Property VMotivation to bring symbols in ES6Decorators and how are they usedUse Typescript with native ES6 PromisesClone array in ES6Array Helper Methods in ES6Dynamically load JS inside JSObjects In this section, we've collected important JavaScript examples that deal with objects. Whether you're just starting or you're already familiar with JavaScript and want to practice, take a look at the examples below.Check if a value is object-likeCompare object by property valueCheck for plan ObjectCreate an object from two arraysGet the index of an object by its propertyCheck object in array propertyPrint object by id in an array of objectsAdd dynamic property to objectImplement a filter() for ObjectsAll the methods of an objectConvert an Object to JS ArrayIterate over a JavaScript objectRemove Objects from Associative ArraySubset of a javascript object’s propertiesCheck a JavaScript Object is a DOM ObjectRemove a property from JavaScript objectRemove Objects from Associative ArrayFlatten JavaScript objects into a single-depth ObjectCreating objectsConvert URL Parameters to ObjectFunctionWithin this section, we've compiled important JavaScript Functions-based programming examples. So if you are seeking JavaScript function-based practice question the deep down below.Functions in JavaScriptRegular functions Vs Arrow Iterate over a callback n timesNegate a predicate functionMake a word count in textareaAdd element horizontally in Html pageAdd fade-out effect using pure Delay Function ExecutionFind out the caller functionPreventDefault( ) Vs Return falseCall Vs applyUsing the function* DeclarationMobile Toggle Navigation MenuModify Global Variable in FunctionPromise Before ReturningOverride a JavaScript functionImport JavaScript FileRetrieve Function Parameters DynamicallyDeclare the optional function parametersCheck a function is definedMeasure time taken by a function to executePassing a function as a parameterCall function from it name stored in a stringInvoke Multiple Functions with ArgumentsInvoke Function with Partial ArgumentsRemove Keys from ObjectInvoke Functions with Received ArgumentsRecursionFollow down the below section you will get multiple JavaScript programming examples based on Recursion.Pairs where sum equals XORCount substrings by character frequencySort the array using slow sortSubtract 1 from a Linked ListMaximize odd-indexed array sum with 2M picksCount ways to sum as perfect squaresNumber of M-length sorted arrays from NInsert element at bottom of stackGCD array of Binary Tree verticalsMin cameras to monitor Binary TreeMax plates in increasing size orderMedian of nodes in BST rangeLargest element in an N-ary TreeLCA of deepest leaves in Binary TreeClosest subset sum to K from 2 arraysMin cost to buy at least X chocolatesMaximize word set cost using charactersMax product from largest Graph componentCount non-decreasing paths in Binary TreeTower of HanoiLongest subset of A 0s & B 1sPath to boundary with sum ≤ K in matrixModify Binary Tree using Preorder sumMax score by removing single-char substringsCount outcomes from S coin flipsLongest path ending at vertex V in GraphGenerate all K-number combinations summing to NMinimize difference between sum of two K-length subsetsNumberExplore the list of number-based JavaScript programming examples. Here you will get examples of how to add float numbers, how to make a currency converter, and more number-based examples.Add float numbers Currency Converter in JavaScriptMedian of an array of numbersRound off a number to the next multiple of 5 Convert a negative number to positiveQuotient and remainder by dividing an integerFlatten a given array up to the specified depthStandard deviation of an array of numbersEvaluate binomial coefficient of two integers n and kGCD of ArrayTest a value x against predicate function and returns fn(x) or xCheck two numbers are approximately equalCreate slider to map a range of values RMS Value Of Array in JavaScriptArrayIf you are looking for a practice set of Array programs, then in this section we have mentioned multiple Array-based JavaScript programming examples.Remove array elements until condition is metFilter array values by comparatorPercentile-based number filterRemove elements from array startConvert 2D array to CSVCount duplicate names in objects arrayCount number of data types in an arrayMove elements to array endFlatten a given array up to the specified depthStandard deviation of numbersSymmetric difference between two arraysGet n largest elements from arrayFind unique elements from two arraysGet all elements except firstRemove elements from array endCreate an object from two arraysConvert array to stringSplice an array without mutating the originalSwapping two array elements in a single lineCreate HTML list Assign array values to objectTruncate an array Print object by id in an array of objectsConvert a number into array Print unique elements from two unsorted arrays Transform a JavaScript iterator into an arrayAdd elements in existing array dynamically Replace item from arrayDateTimeHere in the section, we've compiled the most important DateTime JavaScript programming examples. These examples are designed to deepen your understanding of working with date and time in JavaScript.Days until next ChristmasGet tomorrow’s date stringConvert UTC to local dateCheck if two timestamps are same dayGet seconds since epochCompare dates ignoring timeCheck if input date is todayCheck if date is weekendFormat date as MM/DD/YYYY HH:MM:SSConvert date to another timezoneCheck if date < 1 hour agoValidate a dateDay and month of yearStore all dates between two datesConvert seconds to hh:mm:ss formatDisplay date in 12-hour AM/PM formatConverting milliseconds to date.Date three months priorCalculate minutes between two datesYesterday’s dateFirst day of the yearFirst and last date of current monthRemove time from dateCurrent dateCurrent date/time in secondsStringExplore the practice set of String/Text JavaScript examples. All the examples listed below will help you master the art of handling text data efficiently in your JavaScript projects.String to integer without parseIntGenerate all string combinationsReplace line breaks with <br>Split multiline string into arrayConvert image to base64 stringCheck if string is palindromeCount letter occurrences in stringFind longest word in stringUnique characters of stringCreate element from stringFirst three charactersCheck if string is anagramHalf uppercase, half lowercase stringConvert number to stringCount vowels in stringSingle vs double quotes in stringConvert string to RegExpAdd method to String classAbbreviate long number stringFind longest string in arrayRemove non-ASCII charactersChange <textarea> contentGlobally replace forward slashInsert string at specific indexCreate hash from stringRemove character from stringConvert string to floatConvert string to camel caseRegular ExpressionBelow we have listed down Regular Expression JavaScript programming examples. Practice these questions and know the use of break, clone, and more.Replace line breaks with <br>Clone a given regular expressionConvert a string into kebab caseValidate URL using regular expressionDOMIn this DOM dedicated section, we have listed 15 DOM-based JavaScript examples JavaScript. Explore these examples and get to know how to save data in DOM, how to specify class in div, and more.Store data in the DOMSet form action URLStore data to DOMElements by class in divCheck if element has classHow getElementByID worksShadow root usagePurpose of “no-js” classCombine and append elements to divMeta tag infoCheck if element is visibleCheck if object is DOM elementRemove HTML elementReplace DOM elementSet focus to form elementJSONUnder JSON Examples, we've compiled JavaScript JSON-based programming examples. So if you are looking to refine your skills, dive into the examples listed below for practical learning.Read nested objects in DataTablesConvert CSV to JSON and vice versaWork with APIs in JSJSON vs BSONJSON vs AJAXConvert JSON date in JSSwap key and value in JSONSend JSON to serverConvert JS object to JSON stringJSON to HTML tableDeserialize JSON to JS objectPretty print JSONCheck key in JSON objectAdd element to JSON objectRemove a JSON attributeInteresting facts about JSONDifference between JSON and XMLJSON vs XMLConvert JSON text to JS objectModify array value in JSON objectMini ProjectsOnce you have tried all the above JavaScript programming examples, then explore this section to find out the mini JavaScript examples. These examples help you to upskale you logical skills.Design a Text Editor using JavaScriptGenerate a Random Birthday Wishes using JavaScriptDesign a Digital Clock using JavaScriptDesign a Todo List using JavaScriptCreate a Mobile Toggle Navigation Menu using JavaScriptSimple Tic-Tac-Toe Game using JavaScriptDesign a Simple Calculator using JavaScriptDesign a Scientific Calculator using JavaScriptCreate an Image Lightbox Gallery using JavaScriptPreview Image on click in Gallery View using JavaScriptAdd filter with Portfolio Gallery using JavaScriptCreate a Mobile Toggle Navigation Menu using JavaScriptCreate a Hoverable Side Navigation using JavaScript Learning Data Structures with Javascript Comment More info K kartik Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Tutorials Web-Tech Tutorials +1 More Explore JavaScript BasicsIntroduction to JavaScript4 min readVariables and Datatypes in JavaScript6 min readJavaScript Operators5 min readControl Statements in JavaScript4 min readArray & StringJavaScript Arrays7 min readJavaScript Array Methods7 min readJavaScript Strings5 min readJavaScript String Methods9 min readFunction & ObjectFunctions in JavaScript5 min readJavaScript Function Expression3 min readFunction Overloading in JavaScript4 min readObjects in JavaScript4 min readJavaScript Object Constructors4 min readOOPObject Oriented Programming in JavaScript3 min readClasses and Objects in JavaScript4 min readWhat Are Access Modifiers In JavaScript ?5 min readJavaScript Constructor Method7 min readAsynchronous JavaScriptAsynchronous JavaScript2 min readJavaScript Callbacks4 min readJavaScript Promise4 min readEvent Loop in JavaScript4 min readAsync and Await in JavaScript2 min readException HandlingJavascript Error and Exceptional Handling6 min readJavaScript Errors Throw and Try to Catch2 min readHow to create custom errors in JavaScript ?2 min readJavaScript TypeError - Invalid Array.prototype.sort argument1 min readDOMHTML DOM (Document Object Model)9 min readHow to select DOM Elements in JavaScript ?3 min readJavaScript Custom Events4 min readJavaScript addEventListener() with Examples9 min readAdvanced TopicsClosure in JavaScript4 min readJavaScript Hoisting6 min readScope of Variables in JavaScript3 min readJavaScript Higher Order Functions7 min readDebugging in JavaScript4 min read Like