📜  Underscore.js _.sneq() 方法

📅  最后修改于: 2022-05-13 01:56:49.832000             🧑  作者: Mango

Underscore.js _.sneq() 方法

_.sneq()方法 c 检查每个参数是否严格不相等 ( === )因此,相应地返回一个布尔值。

句法:

_.sneq( val1, val2, ..., valn );

参数:此方法需要 n 个值对其进行操作。

返回值:此方法返回一个布尔值。

注意:这在普通 JavaScript 中不起作用,因为它需要安装 underscore.js contrib 库。 Underscore.js contrib 库可以使用npm install underscore-contrib –save 安装。

示例 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);


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);


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);


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

示例 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