A collection of tech notes, personal reflections, and evolving thoughts about whatever’s caught my curiosity.

notes

Fragments

1 April 2022

A common pattern in React is for a component to return multiple elements. Fragments let you group a list of children without adding extra nodes to the DOM.

render() {
  return (
    <React.Fragment>
      <ChildA />
      <ChildB />
      <ChildC />
    </React.Fragment>
  );
}

Short Syntax

Here is the shorter syntax you can use for declaring fragments. It looks like empty tags:

class Columns extends React.Component {
  render() {
    return (
      <>
        <td>Hello</td>
        <td>World</td>
      </>
    );
  }
}

Motivation for fragments in React.

notes

The more green, the merrier

8 March 2022

After the weekend, when I checked my plant in my office, I noticed the new leaves are bigger and brighter. I don’t know why suddenly it made me happy and peaceful. And now I am planning to plant more of them in my office space.

Maybe more green will give you more peace.

notes

TYPE Attribute

2 March 2022

The %TYPE attribute lets use the datatype of a field, record, nested table, database column, or variable in your own declarations, rather than hardcoding the type names.

You can use the %TYPE attribute as a datatype specifier when declaring constants, variables, fields, and parameters. If the types that you reference change, your declarations are automatically updated.

This technique saves you from making code changes when, for example, the length of a VARCHAR2 column is increased. Note that column constraints, such as the NOT NULL and check constraint, or default values are not inherited by items declared using %TYPE.

essay

വീണ്ടുമുണരട്ടെ

28 February 2022
പാതിരാത്രിയിൽ പ്രാന്തിനൊപ്പം കവിത പൂക്കാറുണ്ടുള്ളിൽ പ്രണയത്തോളം മധുരവും പ്രാണനോളം...
notes

undefined and not defined in JS

22 February 2022

undefined

undefined is a property of the global object. That is, it is a variable in global scope. The initial value of undefined is the primitive value undefined.

A variable is ‘declared’, it has its own placeholder (memory is allcoated) but not having the value of itself ‘defined’ hence ‘undefined’. Until the variable has assigned a value, the ‘undefined’ fills that particular placeholder and ‘undefined’ is itself a datatype.

Not Defined

This case comes in error where js engine neither find that particular variable nor its placeholder and cannot find the variable in 1st phase of context (Memory allocation context)

JS is loosely typed language, this means that JavaScript will figure out what type of data you have and make the necessary adjustments so that you don’t have to redefine your different types of data.

References

MDN

notes

Intersection Observer API

20 February 2022

The Intersection Observer API provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or with a top-level document’s viewport.

Syntax to create Intersection Observer API

const observer = new IntersectionObserver(entries => {
console.log(entries)
})
References

MDN Web Docs
webdevsimplified

notes

Pure functions

20 February 2022

A pure function is a function which:

Given the same input, always returns the same output and the Produces have no side effects.

Preoperties

  • No random values
  • No current date/time
  • No global state
  • No mutation of parameters

Benefits

  • Self-documenting
  • Easily testable
essay

ഓർമ്മകളിലേക്ക്

19 February 2022
ഓർമ്മകളിലേക്ക് വീണ്ടും വീണ്ടും തിരികെപ്പോക്കുന്ന മനുഷ്യരുണ്ട്. രാവിലെയെണ്ണീറ്റ് ഒറ്റക്ക്...
notes

Primitive Data types in JS

18 February 2022

In JavaScript, a primitive (primitive value, primitive data type) is data that is not an object and has no methods or properties. There are 7 primitive data types:

  • string
  • number
  • bigint
  • boolean
  • undefined
  • symbol
  • null

All primitives are immutable; that is, they cannot be altered. It is important not to confuse a primitive itself with a variable assigned a primitive value. The variable may be reassigned to a new value, but the existing value can not be changed in the ways that objects, arrays, and functions can be altered.

References

MDN