鉴于这个相当愚蠢的功能,应该如何编写文档" range" PARAM?
/**
* @param {number} value
* @param {Object} range
* @param {number} range['<']
* @param {number} range['<=']
* @param {number} range['>']
* @param {number} range['>=']
*/
function testIsInRange(value, range) {
var threshold;
if ((threshold = range['<'], threshold !== undefined) && !(value < threshold)) {
fail('Value must be less than ' + threshold);
}
if ((threshold = range['<='], threshold !== undefined) && !(value <= threshold)) {
fail('Value must be less than or equal to ' + threshold);
}
if ((threshold = range['>'], threshold !== undefined) && !(value > threshold)) {
fail('Value must be greater than ' + threshold);
}
if ((threshold = range['>='], threshold !== undefined) && !(value >= threshold)) {
fail('Value must be greater than or equal to ' + threshold);
}
}
点和括号表示法似乎都不起作用。属性类型(对象和数字)被识别,但它们的名称不是。