Using Mocha and Chai for unit tests in Node JS projects

ref – Creating the Directory mkdir mocha-chai-demo cd mocha-chai-demo Setting up the package.json in directory /mocha-chai-demo: npm init use defualt for all the options. You will then have a package.json file created, which looks something like this: package name: (mocha-chai-demo) tdd-for-node version: (1.0.0) description: test driven dev for node entry point: […]

Different ways of creating Objects, Object literal vs Object instances


This method creates a new object extending the prototype object passed as a parameter. var b = {} This is equivalent to Object.create(null) method, using a null prototype as an argument. Using function constructor with new

es6 classes

Singleton pattern

literal vs instances

You have just created a […]

recursive divide and conquer on arrays

Quick sort version The divide and conquer recursion on an array occurs when we have dubbed a mid, then recursively go into the left side of the array. Then, the right side. We leave the middle element. Thus we apply recursion on low to (mid-1) print mid (mid+1) to high But how? We recursive into […]

JS classes support 3 kinds of methods review: Javascript Prototype Class Constructors

Static methods Static methods are methods on the constructor function itself, which are not available on instances of the class. You define them by using the static keyword.

Prototype methods Any method that isn’t a constructor or a static method is prototype method. The name comes from […]