Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1130)

Unified Diff: src/runtime.js

Issue 579973002: Add Array.prototype.contains (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Use `array` instead of `O` Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/harmony-array.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index d9e1fe5c994030f40461167faac8b3df4d60ff22..6657d96f4a422337bd967ac815dd6d4c4c488c64 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -576,6 +576,15 @@ function ToInt32(x) {
return %NumberToJSInt32(ToNumber(x));
}
+// ES6, section 7.1.15
+function ToLength(x) {
+ if (%_IsSmi(x) && x >= 0) return x;
+
+ var len = ToInteger(x);
+ if (len <= 0) return 0;
+ return MathMin(len, $Number.MAX_SAFE_INTEGER);
+}
+
// ES5, section 9.12
function SameValue(x, y) {
@@ -590,6 +599,15 @@ function SameValue(x, y) {
return x === y;
}
+// ES6, section 7.2.4
+function SameValueZero(x, y) {
+ if (typeof x != typeof y) return false;
+ if (IS_NUMBER(x)) {
+ if (NUMBER_IS_NAN(x) && NUMBER_IS_NAN(y)) return true;
+ }
+ return x === y;
+}
+
/* ---------------------------------
- - - U t i l i t i e s - - -
« no previous file with comments | « src/harmony-array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698