Lodash _.isOdd() 方法
Lodash_.isOdd()方法检查给定值是否为奇数。
句法:
_.isOdd( value )
参数:此方法接受如上所述和如下所述的单个参数:
- value:此参数保存需要检查奇数的值。
返回值:此方法返回一个布尔值。
示例 1:
Javascript
// Defining Lodash variable
const _ = require('lodash');
// Checking for an Odd
console.log("The Value is odd number : " + _.isOdd(3);
Javascript
// Defining Lodash variable
const _ = require('lodash');
// Checking for an Odd
console.log("The Value is odd number : " + _.isOdd(2);
Javascript
// Defining Lodash variable
const _ = require('lodash');
// Checking for an Odd
console.log("The Value is odd number : " + _.isOdd({});
输出 :
The Value is odd number : true
示例 2:
Javascript
// Defining Lodash variable
const _ = require('lodash');
// Checking for an Odd
console.log("The Value is odd number : " + _.isOdd(2);
输出 :
The Value is odd number : false
示例 3:
Javascript
// Defining Lodash variable
const _ = require('lodash');
// Checking for an Odd
console.log("The Value is odd number : " + _.isOdd({});
输出 :
The Value is odd number : false