Airbnb style guide for Naming

Extension naming .jsx is preferred over .js for file name


PascalCase for naming file and Reference naming

import DashboardHeader from '/DashboardHeader';

Camel case naming for Component instance
Directory Name should be component name and file name should be lowercase as index.jsx



  const dashboardHeader = </DashboardHeader> ;

Async/Await in jS

async/await is built on top of the promise and supports all promise based apis.

async keyword in function

  1. It declares an asynchronous function eg:  async getUsers() {…}
  2. It enables the use of await.
  3. It returns promise. Promise is created when starting the execution of function.

await in async function

  1. await waits for promise to be settled. if promise is fulfilled the result of await is the promise resolved value. if the promise is rejected, await throws the rejection value.
  2. await used in front of promise call, await forces the rest of the code to wait until the promise finished the return result.


For reading more:


Its an alias for !merge which updates the given hash object and returns the updated hash. Basically used to update the value of hash with same key or !merge.

NOTE:  update routine overrides the value of the caller object which keys matches with the parameter pass hash in the update routine.
Usage 1:

  hash1 = { a: 'I am from hash 1'}
  hash2 = { a: 'I am from hash 2'}
   => {:a=>"I am from hash 2"}
   => {:a=>"I am from hash 2"}

usage 2:

  hash1 = { a: 'I am from hash 1'}
  hash2 = { b: 'I am from hash 1'}

    => {:a=>"I am from hash 1", :b=>"I am from hash 1"}

for more details:

Selection sort in ruby

a = [9, 8, 6, 5, 4, 3, 2, 1]

// sorting in ascending order

total_index = a.length - 1
(total_index).times do |i|
  current_top_index = i
  (i + 1).upto(total_index) do |j|
    if a[j] < a[current_top_index]
      temp = a[j]
      a[j] = a[current_top_index]
      a[current_top_index] = temp
a = [1, 2, 3, 4, 5, 6, 8, 9]

Time complexity

Space complexity