I was learning through javascript’s context and .apply() and .call() function and am having trouble with one particular statement.
Math.max.apply( Math, array );
can you explain how it works to provide the maximum number??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
applyis a function’s method that calls a the function with the given context object and arguments provided as an array:Math.maxreturns the largest of zero or more numbers:So, using
apply, you have:That is equivalent to the code above.