Negative number representation

We use “two’s complement” in modern computer system


when different → 1, when same →0

  • X ^ X = 0 (used in cryptography a lot)
  • X ^ ~X = 1s
  • X ^ 1s = ~X (this is how to flip all bits)

Arithmetic shift vs logical shift



The ability to use and manipulate the “this” value of a function is key to good object-oriented programming in JavaScript.


The JavaScript “this” keyword which is used in a function, refers to the object it belongs to.

4 types of “this” binding

  • default binding
  • implicit binding
  • explicit binding
  • new binding

Default binding

default binding when “globalThis” is not set in case of node

default binding when “globalThis” is set



simple example

What is curry?

Currying is a transformation of a function with multiple arguments into a sequence of nested functions with a single argument. The currying allows performing function specialization and composition.

f(a, b,c) callable into f(a)(b)(c)

Simple example 1

Simple example 2