equal comparison of AngularJS API

Usage

  • 1 First, all objects that satisfy such a === 3, will return true in angular.equals (a, b)
  • All objects of the second type, and the attribute values ​​are the same, also returns true
  • 3 NaN and NaN also returns true (in javascript, returns false)
  • Regular 4 also returns true (in javascirpt, / abc / / abc / are considered not equal)

Sample

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
</head>
<body ng-app="myApp">
	<div ng-controller="myCtrl">
		{{ a_equals }}
		{{ user_equals }}
		{{ nan_equals }}
		{{ reg_equals }}
	</div>
	<script type="text/javascript">
	angular.module("myApp",[])
	.controller("myCtrl",function($scope){
		
		var a = 3;
		$scope.a_equals = angular.equals(a,3);//a === 3

		var user1 = {"name":"xing","age":30};
		var user2 = {"name":"xing","age":30};
		$scope.user_equals = angular.equals(user1,user2);

		$scope.nan_equals = angular.equals(NaN,NaN);//in javascirpt is false

		$scope.reg_equals = angular.equals(/abc/,/abc/);// in javascript is false
	});
	</script>
</body>
</html>

Will be running four true

Reproduced in: https: //my.oschina.net/u/204616/blog/545306

Guess you like

Origin blog.csdn.net/weixin_34062469/article/details/91989847