- Redux Quick Start Guide
- James Lee Tao Wei Suresh Kumar Mukhiya
- 82字
- 2021-07-02 12:40:28
Functions as arguments
Functions can be used as arguments for other functions. Let's use the preceding bmi function to check whether a person has an obesity issue. According to the BMI scale, someone with a bmi between 30.0 and 54 is said to have obesity. We will pass a function as an argument, as follows:
const bmi = (weight, height) => weight / (height * height);
const hasObesity = (bmi) => bmi >= 30.0 && bmi <=54;
console.log(hasObesity(bmi(100, 2.2)));
推薦閱讀
- 極簡算法史:從數學到機器的故事
- TypeScript入門與實戰
- JavaScript+jQuery網頁特效設計任務驅動教程(第2版)
- Django開發從入門到實踐
- HTML5+CSS3基礎開發教程(第2版)
- Mastering Ubuntu Server
- Apache Karaf Cookbook
- Python程序設計案例教程
- PHP+MySQL+Dreamweaver動態網站開發實例教程
- GeoServer Beginner's Guide(Second Edition)
- Windows Forensics Cookbook
- Java程序設計
- Express Web Application Development
- SSM開發實戰教程(Spring+Spring MVC+MyBatis)
- Getting Started with Python