- Underscore.JS 教程
- Underscore.JS——主页
- Underscore.JS——概述
- Underscore.JS——设置环境
- Underscore.JS——遍历集合
- Underscore.JS——处理集合
- Underscore.JS——遍历数组
- Underscore.JS——处理数组
- Underscore.JS——函数
- Underscore.JS——映射对象
- Underscore.JS——更新对象
- Underscore.JS——比较对象
- Underscore.JS——实用程序
- Underscore.JS——链接
- Underscore.JS——有用资源
- Underscore.JS——快速指南
- Underscore.JS——有用资源
- Underscore.JS——讨论
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
广告