From 465f3bfd2b72f522119edcc5b1ac58f9a9e06cc6 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 7 Jan 2017 15:23:45 +0200 Subject: [PATCH 1/3] use object shorthand notation --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 94e7fa2c..0edd66b7 100644 --- a/README.md +++ b/README.md @@ -400,9 +400,9 @@ function showDeveloperList(developers) { var experience = developer.getExperience(); var githubLink = developer.getGithubLink(); var data = { - expectedSalary: expectedSalary, - experience: experience, - githubLink: githubLink + expectedSalary, + experience, + githubLink }; render(data); @@ -415,9 +415,9 @@ function showManagerList(managers) { var experience = manager.getExperience(); var portfolio = manager.getMBAProjects(); var data = { - expectedSalary: expectedSalary, - experience: experience, - portfolio: portfolio + expectedSalary, + experience, + portfolio }; render(data); @@ -440,9 +440,9 @@ function showList(employees) { } var data = { - expectedSalary: expectedSalary, - experience: experience, - portfolio: portfolio + expectedSalary, + experience, + portfolio }; render(data); From 7035841c0370ebe2a7f8084bc5a8e3353f95f406 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 7 Jan 2017 15:32:37 +0200 Subject: [PATCH 2/3] remove default constructors Ref: http://eslint.org/docs/rules/no-useless-constructor --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index 0edd66b7..c13fd5a8 100644 --- a/README.md +++ b/README.md @@ -623,10 +623,6 @@ Array.prototype.diff = function(comparisonArray) { **Good:** ```javascript class SuperArray extends Array { - constructor(...args) { - super(...args); - } - diff(comparisonArray) { var values = []; var hash = {}; @@ -1155,10 +1151,6 @@ class Rectangle { } class Square extends Rectangle { - constructor() { - super(); - } - setWidth(width) { this.width = width; this.height = width; @@ -1186,8 +1178,6 @@ renderLargeRectangles(rectangles); **Good**: ```javascript class Shape { - constructor() {} - setColor(color) { // ... } From 14e83d5ce922fac5f9ef726447ea6e4b44b70785 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 7 Jan 2017 15:37:00 +0200 Subject: [PATCH 3/3] use functional Array methods Also exclude hidden type coercion from array elements comparing. --- README.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/README.md b/README.md index c13fd5a8..96f5dd00 100644 --- a/README.md +++ b/README.md @@ -624,20 +624,7 @@ Array.prototype.diff = function(comparisonArray) { ```javascript class SuperArray extends Array { diff(comparisonArray) { - var values = []; - var hash = {}; - - for (var i of comparisonArray) { - hash[i] = true; - } - - for (var i of this) { - if (!hash[i]) { - values.push(i); - } - } - - return values; + return this.filter(elem => !comparisonArray.includes(elem)); } } ```