JavaScript closure

In JavaScript when a function is nested inside of another function, the inner function has access to the outer function scope. The innermost function has access to all the parent scopes and therefore has closure over all of them. Because the inner function has closure over the parent functions, it is able to use the variables, even when the function has returned.

JavaScript lexical scope

In this blog post, I will explain how the lexical scoping model is defined and how it is being used in JavaScript. I will go over how the lexical scope differs from the dynamic scoping model by using the example of the how the execution of a JavaScript program would look like if it was using the dynamic scoping model and after that showing how it is done in JavaScript using the lexical scoping model.

JavaScript understanding scope

To efficiently program in javascript you will have to understand the principle of scope. The javascript scope is the set of variables you have access to, this goes for both objects and functions since in javascript functions and objects are also variables. To better understand scope we will have to look into how javascript is being executed. By taking a look at the compiler, engine and the scope.

IOC Container Service Lifetimes in ASP.NET Core

When you're building a web application it is important to be able to control the service lifetime of the registrations in your container. The reason is that some of your objects might require being instantiated on every request while another instance should be unique and should only be instantiated once in the application lifespan.

Hoisting in JavaScript

In JavaScript, a variable can be declared after it has been used. In other words, a variable can be used before it has been declared, this is called hoisting. The term hoisting cannot be found in the official JavaScript documents, but the term was invented as a general way of thinking about what happens in the compilation phase when variables and function declarations are moved to the top of their containing scope. To be exact the variables are not being moved to the top of the scope, but they're being stored in memory doing the compile phase, so they can be used in the execution phase.

What is 'this' in JavaScript

In a language like C# 'this' always points to the containing class, so going into JavaScript you might think that 'this' always points to the containing function, but this is not the case. Sometimes you will find 'this' actually pointing to the function, but other times you will find it pointing to the global object or to something third. In this post, I will go through the rules of how the 'this' binding is being set, so hopefully, development in JavaScript using the 'this' keyword will get easier and less confusing.

Webpack 2 handling Sass

A lot of developers today write their styles in a transpiled language like Sass or Less. Creating a setup is needed to transpile, bundle and minify the code. In this post I will show you how to setup a build flow with Webpack 2, to transpile, bundle, minify and add vendor specific CSS to the final bundle.

Webpack 2 bundling using Babel

Browser compatibility can be a pain and make you not use the new features of JavaScript ES6 and beyond. Luckily there is a savior, Babel. Babel is a way to transpile ES6+ JavaScript code to your version of choice. In this post I will show you have to setup Babel using Webpack 2 to transpile ES6 to ES5 JavaScript.

Webpack 2 bundling JavaScript

JavaScript heavy websites are becoming more and more common. To reduce the number of HTTP requests and solve the problems with which order scripts should be loaded, tools like Webpack has emerged. In this post, I will show you how to setup Webpack 2 and use it to bundle JavaScript files. To follow the guide you should have node package manager installed and have a basic understanding of modules in JavaScript.

Response Caching in ASP.NET Core

Using caching is an essential way to improve performance in your application. With ASP.NET Core you have to download and setup the associated middlewares. In this blog post, I will introduce you to response caching and show how to implement it in a web application.