JavaScript Examples

The JavaScript Programming Examples are the best way to practice and learn JavaScript questions. This JavaScript Examples are categorized based on the topics, including Objects, Functions, Arrays, Strings, DOM, and many more. These programming examples contain all possible approaches to solve the problem.

JavaScript Examples

JavaScript Examples

Introduction to JavaScript
JavaScript Tutorial

JavaScript Programming Examples Topics

ES6 Questions:

1 Difference between ES6 and TypeScript
2 How to check two numbers are approximately equal in JavaScript?
3 How to declare variables in different ways in JavaScript?
4 How to replace the names of multiple object keys with the values provided using JavaScript?
5 How to get the first non-null/undefined argument in JavaScript?
6 Shorthand Syntax for Object Property Value in ES6
7 Motivation to bring symbols in ES6
8 What are decorators and how are they used in JavaScript?
9 How to use Typescript with native ES6 Promises?
10 How to clone array in ES6?
11 Array Helper Methods in ES6
12 How to dynamically load JS inside JS?

Objects Questions:

1 How to check if a value is object-like in JavaScript?
2 How to compare two objects to determine the first object contains equivalent property values to the second object in JavaScript?
3 How to check if the provided value is an object created by the Object constructor in JavaScript?
4 How to convert two-dimensional array into an object in JavaScript?
5 How to create an object from two arrays in JavaScript?
6 JavaScript | Get the index of an object by its property.
7 How to use array that include and check an object against a property of an object?
8 How to print object by id in an array of objects in JavaScript?
9 How to create dynamic values and objects in JavaScript?
10 How to add a property to a JavaScript object using a variable as the name?
11 How to implement a filter() for Objects in JavaScript?
12 How to get all the methods of an object using JavaScript?
13 How to convert an Object {} to an Array [] of key-value pairs in JavaScript?
14 How to iterate over a JavaScript object?
15 How to add an object to an array in JavaScript?
16 How to get the last item of JavaScript object?
17 How to remove Objects from Associative Array in JavaScript?
18 How to remove duplicates from an array of objects using JavaScript?
19 How to get a key in a JavaScript object by its value?
20 How to push an array into the object in JavaScript?
21 How to get a subset of a javascript object’s properties?
22 How to check a JavaScript Object is a DOM Object?
23 How to remove a property from JavaScript object?
24 Flatten JavaScript objects into a single-depth Object
25 Creating objects in JavaScript (4 Different Ways)
26 Convert URL parameters to a JavaScript Object

Functions Questions:

1 Functions in JavaScript
2 Difference between regular functions and arrow functions
3 How to iterate over a callback n times in JavaScript ?
4 How to negate a predicate function in JavaScript ?
5 How to make a word count in textarea using JavaScript ?
6 How to add an element horizontally in Html page using JavaScript?
7 How to add fade-out effect using pure JavaScript ?
8 How to add fade-in effect using pure JavaScript?
9 How to implement a function that enable another function after specified time using JavaScript ?
10 Ways to implement Object.values() in JavaScript
11 How to get the index of the function in an array of functions which executed the fastest in JavaScript?
12 How to find out the caller function in JavaScript?
13 When to use PreventDefault( ) vs Return false in JavaScript?
14 What is the difference between call and apply in JavaScript?
15 Using the function* Declaration in JavaScript
16 Create a Mobile Toggle Navigation Menu using HTML, CSS and JavaScript
17 How to change the value of a global variable inside of a function using JavaScript ?
18 How to wait for a promise to finish before returning the variable of a function?
19 How to override a JavaScript function ?
20 How to include a JavaScript file in another JavaScript file ?
21 How to get the javascript function parameter names/values dynamically?
22 How to declare the optional function parameters in JavaScript ?
23 How to check a function is defined in JavaScript ?
24 How to measure time taken by a function to execute using JavaScript?
25 Passing a function as a parameter in JavaScript
26 How to call function from it name stored in a string using JavaScript?
27 How to create a function that invokes each provided function with the arguments it receives using JavaScript ?
28 How to create a function that invokes function with partials appended to the arguments in JavaScript ?
29 How to remove the key-value pairs corresponding to the given keys from an object using JavaScript ?
30 How to create a function that invokes each provided function with the arguments it receives using JavaScript ?

Recursion Questions:

1 Count pairs up to N having sum equal to their XOR
2 Count substrings having frequency of a character exceeding that of another character in a string
3 Sort the array using slow sort
4 Subtract 1 from a number represented as Linked List
5 Maximize sum of odd-indexed array elements by repeatedly selecting at most 2*M array elements from the beginning
6 Count ways to represent a number as sum of perfect squares
7 Number of M-length sorted arrays that can be formed using first N natural numbers
8 Program to insert an element at the Bottom of a Stack
9 Generate an array representing GCD of nodes of each vertical level of a Binary Tree
10 Minimum number of cameras required to monitor all nodes of a Binary Tree
11 Maximum number of plates that can be placed from top to bottom in increasing order of size
12 Median of all nodes from a given range in a Binary Search Tree ( BST )
13 Largest element in an N-ary Tree
14 Lowest Common Ancestor of the deepest leaves of a Binary Tree
15 Sum of subsets nearest to K possible from two given arrays
16 Minimum cost of purchasing at least X chocolates
17 Maximize cost of forming a set of words using given set of characters
18 Maximum product of a pair of nodes from largest connected component in a Graph
19 Count paths in a Binary Tree consisting of nodes in non-decreasing order
20 Tower of Hanoi
21 Length of longest subset consisting of A 0s and B 1s from an array of strings
22 Check if a path exists from a given cell to any boundary element of the Matrix with sum of elements not exceeding K
23 Modify Binary Tree by replacing each node with the sum of its Preorder Predecessor and Successor
24 Maximum score possible by removing substrings made up of single distinct character
25 Count all unique outcomes possible by performing S flips on N coins
26 Length of the longest path ending at vertex V in a Graph
27 Generate all possible combinations of K numbers that sums to N
28 Minimize difference between sum of two K-length subsets

Math Questions:

1 How to add float numbers using JavaScript ?