Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

JavaScript MIN

The JavaScript MIN function is a Math function, which returns the Minimum or Smaller value from the specified set of expression. The syntax of the JavaScript MIN function is

Math.min(Value1, Value2, ...ValueN);

Value1: It can be a number or a valid numerical expression.

  • If we provide Zero arguments, MIN function returns Positive Infinity
  • If the value argument is a positive or negative integer, the MIN function will return the Output.
  • Any of the value is not a number, and then MIN function returns NaN.
  • If it is Null, the MIN function converts Null value to Zero.

JavaScript MIN Function Example

The JavaScript MIN function is used to return the Minimum or Smaller value from the given set of numbers. In this example, We are going to find the Minimum value from a different set of data types and display the output

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript MIN Function </title>
</head>
<body>
  <h1> JavaScript MIN Function </h1>
  <p id = "Pos"></p>
  <p id = "Neg"></p>
  <p id = "Dec"></p>
  <p id = "Neg_Dec"></p>
  <p id = "Str"></p>
  <p id = "Str1"></p>
  <p id = "Null"></p>
  <p id = "Multi"></p>
  <script>
    document.getElementById("Pos").innerHTML = Math.min(10, 2, 3);
    document.getElementById("Neg").innerHTML = Math.min(-1, 2, -9, -7);
    document.getElementById("Dec").innerHTML = Math.min(12.50, 4.05, 9.35, 14.58);
    document.getElementById("Neg_Dec").innerHTML = Math.min(-3.10,-6.05, -22.04, -15.08);
    document.getElementById("Str").innerHTML = Math.min(2, "3", "1", 9);
    document.getElementById("Str1").innerHTML = Math.min(2, "String");
    document.getElementById("Null").innerHTML = Math.min(4, null, 5, 9);
    document.getElementById("Multi").innerHTML = Math.min();
  </script>
</body>
</html>
JavaScript MIN Function

We used the MIN Function on the String value. The following statement converts the “3” and “1” to integers and return the output.

document.getElementById("Str").innerHTML = Math.min(2, "3", "1", 9);

Next statement, We tried JavaScript MIN Function on “String”. As we said before, it returns NaN (Not a Number) as output

document.getElementById("Str1").innerHTML = Math.min(2, "String");

We used MIN Math Function along with Null value. Here the null argument is converted to Zero.

document.getElementById("Null").innerHTML = Math.min(4, null, 5, 9);

Last, We tried JS MIN Function without arguments (Zero arguments), and this will return Infinite

Filed Under: JavaScript

  • SQL DML, DDL, DCL & TCL Cmds
  • SQL NOT EXISTS Operator
  • SQL UPDATE from SELECT
  • SQL AFTER UPDATE Triggers
  • SQL Get Column Names in Table
  • SQL IF ELSE
  • SQL ACID Properties
  • SQL FOR XML PATH
  • Java Two Dimensional Array
  • Java Perfect Number Program
  • Java Count Digits in a Number
  • C Compare Two Strings Program
  • C Print Prime Numbers 1 to 100
  • C program to Reverse a String
  • C Palindrome Number Program
  • C Program for Palindrome String
  • C Remove Duplicate String Chars
  • C Square of a Number Program
  • C Sum and Average of N Number
  • Python Fibonacci Series program
  • Python Area Of Circle Program
  • Python Prime Numbers 1 to 100
  • Python Program for Leap Year
  • Tableau Rank Calculation
  • Tableau Google Maps usage
  • Power BI Format Dates
  • Power BI Top 10 Filters
  • Power BI – Create Hierarchy
  • Power BI DAX Math Functions
  • Learn SSIS in 28 Days
  • SSIS Transformations
  • SSIS Incremental Load
  • SSRS Drill Through Reports
  • SSRS Drill Down Reports
  • R Programming Tutorial

Copyright © 2021· All Rights Reserved by Suresh.
About | Contact | Privacy Policy