- 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)));
推薦閱讀
- 大學計算機基礎(第二版)
- 現代C++編程:從入門到實踐
- Web應用系統開發實踐(C#)
- Learning RxJava
- Python自動化運維快速入門(第2版)
- Cocos2d-x游戲開發:手把手教你Lua語言的編程方法
- INSTANT Sencha Touch
- Apache Karaf Cookbook
- Unity 5.x By Example
- Visual Basic 6.0程序設計實驗教程
- Modern C++ Programming Cookbook
- Learning JavaScript Data Structures and Algorithms(Second Edition)
- SpringBoot從零開始學(視頻教學版)
- Visual C++從入門到精通(第2版)
- Java程序設計教程