The final week and I’m ready for the new course already!

Talk about something you learned this week.

This week I have finally properly learned how to write out a unit test and using separate files to import and export testing. Using chai as an assertion tool is extremely helpful. There are a few hiccups that came along the way as far as equal vs deep equal in chai, but overall, unit testing along with many things in programming, isn’t quite so bad. Coming up with unit tests how ever is not quite that simple. I’ve also learned how to properly set up a package.json environment and implement lodash into my code. Lodash is a quick and easy way to manipulate and return altered objects.

Explain Function.prototype.bind()

The ole bind prototype, we never think about it until it’s necessary. Obviously in object oriented progamming using classes one can create the instance of an object and then attach methods upon them but there’s another way to attach a function to an object using this.bind. Example below.

function getMonthlyFee(fee){
var remaining = - fee; = remaining;
return +' remaining balance:'+remaining;

Above we created a function that returns the name of the person, and the balance they have left to pay. We then create an object pertaining to the function:

var josh = {name:'Josh Green', total:500};

Now we bind the object to the function and by passing the name and total values we can use them to return the ‘’ and ‘remaining balance’.

var getRachelFee = getMonthlyFee.bind(rachel, 90);
getRachelFee();//Rachel Green remaining balance:410
getRachelFee();//Rachel Green remaining balance:320

Describe event bubbling.

The bubbling principle is simple.

When an event happens on an element, it first runs the handlers on it, then on its parent, then all the way up on other ancestors.

Let’s say we have 3 nested elements FORM > DIV > P with a handler on each of them:

If we were to add an alert(‘123)’ onclick event to FORM, DIV, AND P, and then clicked on the P, through bubbling, the initial alert would be coming from the P tag, then another alert from the DIV, and finally an alert from the FORM. Due to bubbling, it’s starting at the most deeply nested element, and working it’s way up.

What’s the difference between the window load event and document DOMContentLoaded event?

From the Mozilla Developer Center:

The DOMContentLoaded event is fired when the document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading (the load event can be used to detect a fully-loaded page).

In short DOMContentLoaded is literally only waiting for the basic skeleton of the DOM tree to load, where as the window load event is waiting all the sub-links and scripts to be loaded.

Describe the call stack.

A call stack is a mechanism for an interpreter (like the JavaScript interpreter in a web browser) to keep track of its place in a script that calls multiple functions — what function is currently being run and what functions are called from within that function, etc.

Call stack refers to who is next in line to be called through JS. If we have two functions, one alerting ‘6’ in the browser window, and the next one logging (‘chicken’), first we would see the alert ‘6’ appear in the call stack, once that has been run, it would be removed and the new function that logs ‘chicken’ would be called into the stack and executed.




Love podcasts or audiobooks? Learn on the go with our new app.

Creating a Component Library

JS Concepts: Hoisting

Javascript Important Topic Revision

Sending SMS the Low-Code Way with Airtable, Twilio Programmable SMS, and n8n 📱

Binary Tree And How to Search and Insert With Recursive Functions

PHP vs NodeJS: Back-end Decisions

How to install Avalanche NODE.

Fabric.Js Images cropped when loading from json

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


More from Medium


A Laptop that’s almost closed with screen light on

How to master your job search?

How to Fix “err_gfx_d3d_init” in GTA 5? [6 Proven Ways]

Going Out With A Bang!