Engineering Blog

                            

Blog – 2 Column

Ignoring the fact that elements are copied in range loops

Range is the form of for loop that iterates over a slice or map. We may forget or be unaware of how a range loop assigns values, leading to common mistakes. First, let’s remind ourselves how to use a range loop; then we’ll look at how values are assigned. Concepts A range loop allows iterating…

Never using named result paramater

In Go return or result parameters can have a named parameter. Having a named parameter eliminates the necessity of having a variable name along with a return parameter as the user can only use a return keyboard to return the result. When a result parameter is named, it’s initialized to its zero value when the…

Using a filename as a function input

While creating a new function that reads the file, passing the filename as an argument is not considered best practice and might have negative effects such as making it difficult to write test cases for a variety of criteria. Suppose we want to implement a function to count the number of empty lines in a…

Ignoring how defer arguments are evaluated

In order to understand how arguments are processed using the defer keyword, let’s consider a specific example. Suppose we have a function that needs to execute two other functions, called foo and bar. Additionally, this function needs to handle some status information related to its execution. We can use the defer keyword to ensure that…

Misunderstanding variable scope in JavaScript

Misunderstanding variable scope in JavaScript

In this post, we are going to understand variable scope and difference between var, let and const keywords in javascript. Variable scope is tricky concept for new developers., especially in javascript. Most of beginner developers make common mistake like defining the variable inside the function and expecting it to access outside the function. Understanding var,…

Using index as a key in React (anti-pattern)

What are lists in React ? Lists are used to display data which are similar in ordered format . Often they have same type i.e an array of similar kind of data rendered into a list tag using some version of for loop. How does react render lists? DOM Before we learn how react renders lists…

Object references and copying

One of the fundamental differences of objects versus primitives is that objects are stored and copied “by reference”, whereas primitive values: strings, numbers, booleans, etc – are always copied “as a whole value”. That’s easy to understand if we look a bit under the hood of what happens when we copy a value. Let’s start…

Introducing constructors

Introducing constructors

If we need to create multiple object of same shape then one of the way to define the shape of is by using the function. we have to create an empty object, initialize it, and return it. A better way is to use a constructor. A constructor is just a function called using the new keyword. When…