📜  Underscore.js _.seq() 方法

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

Underscore.js _.seq() 方法

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

句法:

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

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

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

注意:这在普通 JavaScript 中不起作用,因为它需要安装 underscore.js contrib 库。

underscore.js contrib 库可以使用npm install underscore-contrib –save 安装。

示例 1:

// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
var eq  = _.seq( 6, 6, 6 );
  
console.log("Each of the arguments is equal to others :", eq);

输出:

Each of the arguments is equal to others : true

示例 2:

// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
var eq  = _.seq( "gfg", "gfg", "gfg" );
  
console.log("Each of the arguments is equal to others :", eq);

输出:

Each of the arguments is equal to others : true

示例 3:

// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
var eq  = _.seq( 1, "1", 1 );
  
console.log("Each of the arguments is equal to others :", eq);

输出:

Each of the arguments is equal to others : false

示例 4:

// Defining underscore contrib variable
var _ = require('underscore-contrib'); 
  
var eq  = _.seq( 1, 12, 1 );
  
console.log("Each of the arguments is equal to others :", eq);

输出:

Each of the arguments is equal to others : false