From 8fedae194bbda4be2234b97108c456bc66786c62 Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Tue, 28 Jan 2020 08:19:15 +0100 Subject: [PATCH] Add more principles. --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 759fa8d..1f14b96 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,29 @@ let ingredients = ['tomato', 'onion', 'mushrooms']; let dressings = ['ketchup', 'mayonnaise']; ``` +### 💩 Put as much code as possible into one line + +_Good 👍🏻_ + +```javascript +document.location.search.replace(/(^\?)/,'').split('&').reduce(function(o,n){n=n.split('=');o[n[0]]=n[1];return o},{}) +``` + +_Bad 👎🏻_ + +```javascript +document.location.search + .replace(/(^\?)/, '') + .split('&') + .reduce((searchParams, keyValuePair) => { + keyValuePair = keyValuePair.split('='); + searchParams[keyValuePair[0]] = keyValuePair[1]; + return searchParams; + }, + {} +) +``` + ### 💩 Do not lock your dependencies Update your dependencies on each new installation in uncontrolled way. Why stick to the past, let's use the cutting edge libraries versions.