- Ext JS 3.0 Cookbook
- Jorge Ramon
- 146字
- 2021-04-01 13:43:45
Effortless range checking for numbers
Now, you'll see how to use Ext JS in order to guarantee that a number falls within a certain range.
How to do it...
The following steps illustrate how to perform range checking on numeric values:
- Create your sample numbers:
var number1 = 30; var number2 = 75;
- Check whether your numbers are within a range:
var constrained = number1.constrain(25, 50); // constrained is 30 because number1 is // within the specified range constrained = number2.constrain(25, 50); // constrained is 50 because number2 is // greater than the max. value in the range
Ext.Number
is a one-function extension of the JavaScript Number
object. The only function of Ext.Number
is constrain(min, max)
, which simply uses methods of the Math
JavaScript object to accomplish the range checks on the given number.
constrain: function(min, max) { return Math.min(Math.max(this, min), max); }
推薦閱讀
- 中文版3ds Max 2013-VRay效果圖制作從新手到高手
- VR新未來(lái)
- 中文版AutoCAD 2015實(shí)用教程
- After Effects CC影視后期制作實(shí)戰(zhàn)從入門到精通
- Photoshop CC 2017實(shí)戰(zhàn)基礎(chǔ)培訓(xùn)教程(全視頻微課版)
- 邊做邊學(xué):Photoshop圖像制作案例教程(Photoshop CC 2019·微課版)
- 中文版Photoshop CS6平面設(shè)計(jì)實(shí)用教程(第2版)
- 綁定的藝術(shù):Maya高級(jí)角色骨骼綁定技法(第2版)
- SPSS統(tǒng)計(jì)分析
- AutoCAD 2016入門與提高(超值版)
- 中文版Photoshop CS6從新手到高手(超值版)
- Photoshop CS6中文版基礎(chǔ)與實(shí)例教程(第6版)
- 短視頻剪輯基礎(chǔ)與實(shí)戰(zhàn)應(yīng)用(剪映電腦版)
- CorelDRAW X6平面設(shè)計(jì)與制作案例教程
- 中文版3ds Max 2016/VRay效果圖制作實(shí)戰(zhàn)基礎(chǔ)教程(全彩版)