Things to try in your next JS project

Books on shelf
Books on shelf
Photo by Greg Rakozy on Unsplash.

1. Use Default Arguments Instead of Short-Circuiting or Conditionals

2. Handling Multiple Conditions

3. Replacing Switch With Dynamic Key-Value Pair (i.e. Object Literal)

4. Avoid Too Many Function Params

5. Set Default Objects With Object.assign

When to use Tilde(~) or Caret(^)

Photo by Pankaj Patel on Unsplash
npm install somePackage --save
"somePackage": "^3.5.3",

What is it?


Tilde(~) VS Caret(^)

  • ~ freezes major and minor numbers
  • It is used when you’re ready to…

Take a minute to Make a Cross Check!

Hippocratic Oath for SE’s. Photo by Artem Kniaz on Unsplash
  • I…

Load Remote Data, Parse, and Render in UI.

Photo by Vojtech Bruzek on Unsplash
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false

Here is one way you can clean up your function parameters

Photo by Curology on Unsplash

The Scenario

function myFunction(employeeName,jobTitle,yrExp,majorExp){
console.log(`Meet ${employeeName}`);
console.log(`He is working as ${jobTitle}`);
console.log(`He has ${yrExp} year of Experience`);
console.log(`He is an expert in ${majorExp}`);
myFunction("John","Project Manager",12,"Project Management");
Meet John
He is working as Project Manager
He has 12 year of Experience
He is an expert in Project Management

The Problem

Violation of ‘clean code’ principle

Make your pull requests more productive

Photo by Sigmund on Unsplash

Simple, yet powerful protocols you can follow in 2021

Photo by CDC on Unsplash

“Code never lies, comments sometimes do.” — Ron Jeffries

Commenting is the “art” of describing what your program is going to do in “high level” English statements.

1. Only comment things that have business logic complexity

function hashIt(data) {
// The hash
let hash…

“There are only two hard things in computer science: cache invalidation and naming things.” — Phil Karlson

A large collection of books at a library.
A large collection of books at a library.
Photo by Zaini Izzuddin on Unsplash

What’s (P)A/HC/LC?

prefix? + action (A) + high context (HC) + low context? (LC)

What’s a Prefix?

Improve your code readability with these tips

Photo by Mihai Surdu on Unsplash

1. Follow S-I-D

/* Bad */
const a = 5 // "a" could mean anything
const isPaginatable = (postsCount >…

Who needs an MIT license when you can have a Beerware license?! 😂

Photo by Bill Oxford on Unsplash

A software license is a legal instrument (usually by way of contract law, with or without printed material) governing the use or redistribution of software.

1. Beerware license: Buy the publisher a drink.

* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can…


Software Writer || Javascript Journalist || Now Learning Flutter.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store