Underscore.JS——isEqual 方法



语法

_.isEqual(object, other)

isEqual 方法通过对象与其他对象精确比较。请参见以下示例:

示例

var _ = require('underscore');

var student = {name: 'Sam', age: 10, class: { name: '10th', section: 'B'}}
var student1 = {name: 'Sam', age: 10, class: { name: '10th', section: 'B'}}
// Example: Compare student with student1 using ==
console.log(student == student1);

var result = _.isEqual(student, student1);
console.log(result);

tester.js中保存上述程序。运行以下命令来执行此程序。

命令

\>node tester.js

输出

false
true
underscorejs_comparing_objects.htm
广告