Tag: JavaScript

Rest and Spread operators in JS

By placing … before the arrayname as you are passing the array as a argument when calling a function, you can split an array up so the function will see each array value as different arguments. By placing … before an parameter in the function declaration, values that get sent when calling the function gets …

Arrow Functions in ES6

Easiest way to think of Arrow Functions is to think of them as anonymous functions. Please note that you might find them acting differently when working with ‘this’ though! Example, lets see if we can gather all ford cars total km: If we refactor this with arrow functions we get: We can continue to refactor …

Var, let and const variable declarations in ES6

Until ES5 JavaScript only had ‘var’ to declare variables. If you tried out other languages you might find it a bit strange or even a relief not having to think hard about what type of ¬†variable you are creating. In most other languages you have to decide up front what data type it is, where …

JavaScript30

I’ve decided to take up Wes Bos 30 day javascript challenge! My coding progress¬†will be documented on Github as “proof” and I will try to keep this blog up to date with posts of what I’ve learned. Not only for others but also for myself to have as a reference in the future. Further posts …

Days 38-60 failing 60 days coding challenge

After getting seriously ill I got drenched in workload and had to focus on building a WordPress theme from scratch. Designing, wireframing, developing, devops, sysadmin… Took all the time I had and I sadly failed this challenge. I wish I will get time in order to do this challenge again, I highly enjoyed it and …

DOM AND EVENTS

DOM TRAVERSING Old common ways to traverse the DOM: getElementById always run as: document.getElementById getelementsByTagName could be on any node…document as well. getElementsByClassName New way: Selectors API querySelector() and querySelectorAll USING ARRAY METHODS ON A NODELIST The nodelist you get when using querySelectorAll() is not of the same prototype as array and lacks many of …

Math functions in JavaScript

Math is a global variable(namespace) for built in constants and functions that are very handy when developing. I will go through the most common ones in this article: Starting with the most common constant, PI: To get the absolute difference between numbers without getting a negative number you can use the absolute function that is …

Functional Classes in JavaScript (ES5)

This is tricky subject as JavaScript didn’t have classes in the language before 2015. So when classes was talked about before ES6 it was different ways to achieve the same functionality Classes have in other languages though it wasn’t strictly classes. Functional classes is one of those ways. It could be boiled down to that …

Object Decorator Pattern in JavaScript

We will start by creating 2 objects, that are persons with a single property. Their Age and we want to have functionality to make these people get older by 1 year at a time so we add 1 to each of our persons age. Refactored step 1: We will start with creating a function called …

Prototype Chaining in JavaScript

Prototype chaining is useful to share properties from one object to another. Let’s illustrate through code First we declare our shallowCopy function which is one of the most common ways to copy an object. You can find it in here: https://code.support/code/javascript/shallow-copy/ Another way to create an object out of another is using the built in …