_.sneq()方法c争论是否每个论点是严格不等于(===) 每个其他。因此,相应地返回布尔值。
用法:
_.sneq( val1, val2, ..., valn );
参数:此方法采用n个值对其进行运算。
返回值:这种方法返回一个布尔值。
注意:由于它需要安装underscore.js contrib库,因此在常规JavaScript中将无法使用。可以使用npm install underscore-contrib -save安装Underscore.js contrib库。
范例1:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var eq = _.sneq( 1, 2, 3 );
console.log("Each arguments are not "
+ "equal to each other:", eq);
输出:
Each arguments are not equal to each other:true
范例2:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var eq = _.sneq( 2, 2, 2 );
console.log("Each arguments are not "
+ "equal to each other:", eq);
输出:
Each arguments are not equal to each other:false
范例3:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var eq = _.sneq( "2", 2, 2 );
console.log("Each arguments are not "
+ "equal to each other:", eq);
输出:
Each arguments are not equal to each other:true
范例4:
Javascript
// Defining underscore contrib variable
var _ = require('underscore-contrib');
var eq = _.sneq( "2", "2", "2" );
console.log("Each arguments are not "
+ "equal to each other:", eq);
输出:
Each arguments are not equal to each other:false
注:本文由纯净天空筛选整理自GeeksforGeeks大神的英文原创作品 Underscore.js _.sneq() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。