learn
Track Created By / Modified By for Records in AdonisJS
· ☕ 1 min read
AdonisJS provided a quick way to track created and updated times, but does not provide shortcuts to track the user who created or last updated the record. Doing so is quite easy. Modify the migration script to include created_by_id and updated_by_id. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 // todoschema.

The Right Way to Receive Parameters in AdonisJS Controller
· ☕ 2 min read
Quickly and easily pass parameters to controller methods from your request. See Start creating your backend application in AdonisJS to get started You can quickly scaffold a controller in Adonis using the following command - 1 adonis make:controller Todo --type http If you want to receive parameters from input, you would do the following -

Create a functional backend in AdonisJS under 5 minutes
· ☕ 5 min read
AdonisJS provides a really quick way to scaffold your way to a great back-end application. Let us start creating a simple to-do app called ‘ado’ in this post. We will see how we can create this with simple commands and have your API ready in no time. Install AdonisJS Download and install Node if you don’t have it in your system.

Spread Operators in Javascript
· ☕ 3 min read
A spread operator (...) provides a quick way to expand a Javascript object or array. Array or object is a collection of values. Accessing individual values within the array will require one to use a loop. 1 2 3 4 5 6 7 8 9 10 const fruits = ["orange", "apple"]; for (let i = 0; i < fruits.

Variable Scoping in Javascript
· ☕ 5 min read
Scope of a variable refers to the visibility of that variable. Since the visibility of a variable also determines whether it can be referenced in a valid way, scopes are said to define the ‘life time of a variable’. Scopes in Javascript can be global to the program, or local to the specific block and function.

Operator Precedence in Javascript
· ☕ 2 min read
Operator precedence includes unary, increment, basic arithmetic, logical and assignment operators - roughly in that order. The precedence can be remembered by BEUDMASLAS. brackets exponent unary & prefixed increment / decrement division multiplication addition subtraction logical assignment suffixed increment / decrement Not quite exciting as BODMAS or PEDMAS (math, anyone?

Javascript New Keyword
· ☕ 2 min read
New operator is used to initialize objects and create a new instance of the object. You would have seen new used in the object context in an earlier post. The usage is something like the below - 1 2 let worldExists = new Boolean(false); console.log(worldExists); // [Boolean: false] worldExists is an object that has a value of type ‘boolean’.

Rest Parameter in Javascript
· ☕ 1 min read
Rest parameter enables you to signify an ‘infinite’ parameter to a function. ... serves two purposes in Javascript - Spread operator - know what spread operators can do Rest parameter for a function Rest parameter just tells Javscript that there can be zero or infinite parameters for the function.

Object Assign Method in Javascript
· ☕ 1 min read
assign method of an object allows us to merge two objects quickly. 1 2 3 4 5 const name = { name: "earth" }; const position = { position: 3 }; const planets = Object.assign(name, position); console.log("planets: ", planets); // { name: 'earth', position: 3 } You can also use Object.

Property Descriptors in Javascript
· ☕ 2 min read
Property descriptors define property behaviour. They are attributes of the property. Everything is an object in Javascript. Yes, I know - except those pesky things called primitives on which objects are built. We saw some (quick discussions on objects and properties)[/objects-and-props-in-javascript/] before - but I wanted to outline the descriptors further.

Currying in Javascript
· ☕ 2 min read
Currying is a technique of splitting functions with one or more arguments into a sequence of functions that are invokable with predefined arguments. In other words, you can split fn (a,b,c) into fn(a)(b)(c). That was not quite helpful - let us see an example. 1 2 3 4 5 6 let getSquared = (x, y) => { return x * y; }; let getSquared = getProduct.

Comma operator in Javascript
· ☕ 2 min read
Did you know how to use comma operator in Javascript? A simple , can separate expressions in the same statement, evaluate left-to-right in the expression, pick the right most valid value as the result, and confuse other developers - all within the blink of an eye. We have discussed about operators when discussing operator precedence.

Javascript `typeof` issues and what to do about them
· ☕ 2 min read
typeof is useful but has inherent issues. There are gaps between what a developer expects in terms of consistency and what typeof delivers. Let us look at a few examples - 1 2 const i = 1; console.log(typeof i); // number typeof is a unary operator, and does not require brackets.