Activity Forums Salesforce® Discussions What is the use of math.ceil in Lightning Component in Salesforce?

  • Shubham

    Member
    April 2, 2020 at 5:37 pm

    Hi Deepak,
    The Math.ceil() function always rounds a number up to the next largest whole number or integer.
    Note: Math.ceil(null) returns integer 0 and does not give a NaN error
    ek 2.5=3, 2=2, -7.004=-7.
    we also have Math.floor
    Math.floor() function returns the largest integer less than or equal to a given number.
    it can be used in a lot of ways in your lightning component,
    for ex;- In pagination
    where your total no of records are 20, and your page size is 8, to go to the last page,
    where page no is being calculated as totalrecords/pagesize,
    i this case 2.5, math.ceil(2.5) returns 3, and we have our page no

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos