diff --git a/README.md b/README.md index 40e2bd4c6..1cfa93f91 100644 --- a/README.md +++ b/README.md @@ -4503,10 +4503,10 @@ isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true Returns the maximum of the given dates. -Use `Math.max.apply()` to find the maximum date value, `new Date()` to convert it to a `Date` object. +Use the ES6 spread syntax with `Math.max` to find the maximum date value, `new Date()` to convert it to a `Date` object. ```js -const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates)); +const maxDate = dates => new Date(Math.max(...dates)); ```
@@ -4530,10 +4530,10 @@ maxDate(array); // 2018-03-11T22:00:00.000Z Returns the minimum of the given dates. -Use `Math.min.apply()` to find the minimum date value, `new Date()` to convert it to a `Date` object. +Use the ES6 spread syntax to find the minimum date value, `new Date()` to convert it to a `Date` object. ```js -const minDate = (...dates) => new Date(Math.min.apply(null, ...dates)); +const minDate = dates => new Date(Math.min(...dates)); ```
@@ -4727,6 +4727,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]); ```js + const lengthIs4 = checkProp(l => l === 4, 'length'); lengthIs4([]); // false lengthIs4([1,2,3,4]); // true diff --git a/docs/date.html b/docs/date.html index 2fdc79f00..bb54da801 100644 --- a/docs/date.html +++ b/docs/date.html @@ -135,7 +135,7 @@
isBeforeDate(new Date(2010, 10, 20), new Date(2010, 10, 21)); // true
 

Recommended Resource - JavaScript: The Hard Parts

Take your JavaScript to the next level. Gain an understanding of callbacks, higher order functions, closure, asynchronous and object-oriented JavaScript!

isSameDate

Check if a date is the same as another date.

Use Date.prototype.toISOString() and strict equality checking (===) to check if the first date is the same as the second one.

const isSameDate = (dateA, dateB) => dateA.toISOString() === dateB.toISOString();
 
isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true
-

maxDate

Returns the maximum of the given dates.

Use Math.max.apply() to find the maximum date value, new Date() to convert it to a Date object.

const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates));
+

maxDate

Returns the maximum of the given dates.

Use the ES6 spread syntax with Math.max to find the maximum date value, new Date() to convert it to a Date object.

const maxDate = dates => new Date(Math.max(...dates));
 
const array = [
   new Date(2017, 4, 13),
   new Date(2018, 2, 12),
@@ -143,7 +143,7 @@
   new Date(2016, 0, 9)
 ];
 maxDate(array); // 2018-03-11T22:00:00.000Z
-

minDate

Returns the minimum of the given dates.

Use Math.min.apply() to find the minimum date value, new Date() to convert it to a Date object.

const minDate = (...dates) => new Date(Math.min.apply(null, ...dates));
+

minDate

Returns the minimum of the given dates.

Use the ES6 spread syntax to find the minimum date value, new Date() to convert it to a Date object.

const minDate = dates => new Date(Math.min(...dates));
 
const array = [
   new Date(2017, 4, 13),
   new Date(2018, 2, 12),
diff --git a/docs/function.html b/docs/function.html
index dfea172d9..4161d9863 100644
--- a/docs/function.html
+++ b/docs/function.html
@@ -145,6 +145,7 @@ console.log<
 ]);
 

checkProp

Given a predicate function and a prop string, this curried function will then take an object to inspect by calling the property and passing it to the predicate.

Summon prop on obj, pass it to a provided predicate function and return a masked boolean.

const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
 
+
 const lengthIs4 = checkProp(l => l === 4, 'length');
 lengthIs4([]); // false
 lengthIs4([1,2,3,4]); // true
diff --git a/snippets/checkProp.md b/snippets/checkProp.md
index c90195730..ddc49eee2 100644
--- a/snippets/checkProp.md
+++ b/snippets/checkProp.md
@@ -10,6 +10,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
 
 ```js
 
+
 const lengthIs4 = checkProp(l => l === 4, 'length');
 lengthIs4([]); // false
 lengthIs4([1,2,3,4]); // true
diff --git a/test/_30s.js b/test/_30s.js
index 2c0a2ba21..ac59636dd 100644
--- a/test/_30s.js
+++ b/test/_30s.js
@@ -728,7 +728,7 @@ const matchesWith = (obj, source, fn) =>
         : obj[key] == source[key]
   );
 const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
-const maxDate = (...dates) => new Date(Math.max.apply(null, ...dates));
+const maxDate = dates => new Date(Math.max(...dates));
 const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n);
 const median = arr => {
   const mid = Math.floor(arr.length / 2),
@@ -754,7 +754,7 @@ const merge = (...objs) =>
   );
 const midpoint = ([x1, y1], [x2, y2]) => [(x1 + x2) / 2, (y1 + y2) / 2];
 const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
-const minDate = (...dates) => new Date(Math.min.apply(null, ...dates));
+const minDate = dates => new Date(Math.min(...dates));
 const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n);
 const mostPerformant = (fns, iterations = 10000) => {
   const times = fns.map(fn => {