Explorar o código

LibJS: Implement Date.valueOf()

It does exactly the same thing as Date.getTime().
Nico Weber %!s(int64=5) %!d(string=hai) anos
pai
achega
c8cf465174
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      Libraries/LibJS/Runtime/DatePrototype.cpp

+ 7 - 0
Libraries/LibJS/Runtime/DatePrototype.cpp

@@ -73,6 +73,13 @@ void DatePrototype::initialize(GlobalObject& global_object)
     define_native_function("toLocaleTimeString", to_locale_time_string, 0, attr);
     define_native_function("toTimeString", to_time_string, 0, attr);
     define_native_function("toString", to_string, 0, attr);
+
+    // Aliases.
+    define_native_function("valueOf", get_time, 0, attr);
+    // toJSON() isn't quite an alias for toISOString():
+    // - it returns null instead of throwing RangeError
+    // - its .length is 1, not 0
+    // - it can be transferred to other prototypes
 }
 
 DatePrototype::~DatePrototype()