
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Product of two number using HOC - JavaScript
HOC
HOC or Higher Order Functions in JavaScript are a special type of functions that receives another function as argument or have a function set as their return value or do both. HOC along with closures is a very powerful tool in JavaScript.
We are required to write a JavaScript Higher Order Function that can be used to obtain the product of two numbers.
Example
Following is the code −
const num1 = 24; const num2 = 5; const productHOC = num1 => { return product = num2 => { return num1 * num2; }; }; console.log(productHOC(num1)(num2));
Output
Following is the output in the console −
120
- Related Articles
- How to get the product of two integers without using * JavaScript
- Cartesian product of two sets in JavaScript
- Finding product of Number digits in JavaScript
- Recursive product of all digits of a number - JavaScript
- Maximum product of any two adjacent elements in JavaScript
- Find the largest palindrome number made from the product of two n digit numbers in JavaScript
- Product sum difference of digits of a number in JavaScript
- Dash separated cartesian product of any number of arrays in JavaScript
- Largest product of n contiguous digits of a number in JavaScript
- Finding product of an array using recursion in JavaScript
- Maximum Product of Two Numbers in a List of Integers in JavaScript
- Representing number as the power and product of primes in JavaScript
- Difference between product and sum of digits of a number in JavaScript
- Maximum Product Subarray - Using Two Traversals in C++
- Addition of two number using ‘-‘ operator?

Advertisements