Photo by Andrew Haimerl on Unsplash

In this tutorial you’ll learn how to destructuring assignment works in JavaScript. After you read this article, you’ll know how to easily extract properties from objects. Your code will be cleaner and less cluttered.

Extracting Properties From Objects

Let’s start with simple example and create an object first:

const product = {
name: "MacBook Pro",
manufacturer: "Apple",
type: "Laptop",
warranty: {
type: "Standard",
validTo: "2022-12-31"
}
}

In order to get name we can do following, use product.name

console.log(product.name); // "MacBook Pro"

or assign the value to a new variable:

const name = product.name;console.log(name); // "MacBook Pro"

As we can see, name is…


Hot-air balloon drifting in the sky.
Hot-air balloon drifting in the sky.
Photo by Aaron Burden on Unsplash

Do you want to learn and master JavaScript function closures? You’re in the right place!

Preface

To understand this tutorial, you basically just need to know what functions and variables are. After reading and going through the examples here, you’ll leave knowing scope, lexical environment, inner and outer functions, and, obviously, closures!

Basics

Let’s recap some of the basics first. Functions take arguments (parameters) and return a result. For example, a function named add can take two parameters and returns a sum:

function add(a,b) {
return a + b;
}

We could also rewrite this using an anonymous function syntax (i.e., the…


Factory Method Pattern and Node.JS
Factory Method Pattern and Node.JS

If you want to be an exceptional programmer you must be familiar with design patterns. One very common is Factory Method Pattern. In this quick and easy tutorial you’ll learn how to implement and use Factory Pattern using Node.JS.

A Bit of Theory

First of all, why do we use Factory Pattern? If you completed programming course at a University and you learnt object-orientated programming then you should be familiar with concepts like classes, inheritance, objects etc.

Let’s create a simple class called Screen which will be our parent class.

class Screen {
constructor() {

}

getScreenInfo('I am a screen');
}
module.exports = Screen;


2 = 1
2 = 1

Are you tired of solving all these simple maths “problems” that are flooding the Internet? Here is a bit more challenging problem.

However, fear not my friend! No University or advanced Maths skills are required. Just primary (elementary) Maths needed. Have fun!

Step 1

Let’s begin with something really simple to warm up:

a = 1 and b = 1

Therefore, we can write this as:

a = b

Step 2

Now, we can multiply both sides of equation with a. This, as we know from algebra, doesn’t affect the result (i.e. both side are still equal):

a * a = a * b


Adobe Flash Player Uninstaller

Google Chrome removed the Adobe Flash plugin completely at the end of 2020. This marks the end of an era. The era dominated by one proprietary software that for many years defined how the internet looked. Many promised, only Flash delivered.

What Is Flash?

Or better question: What was Flash, and how did it shape and dominate computer entertainment and the early internet industry while being a proprietary product?

Let’s move back in time to the turn of the century. It’s the end of the 90s; Microsoft released MS Windows 98, and the browser war is on the rise. There is no Chrome…


All software engineers should be familiar with design patterns. One of the most known and common one is the singleton pattern. If you want to understand this pattern and how to use it with Node.JS read this quick and easy tutorial.

A bit of theory

We need singleton when we want to make sure there is only one object instantiated. Therefore, instead of creating a new object we need to ensure the constructor was called only once and then we reuse the instance.

We can achieve this by refactoring our class to have:

  • hidden (private)constructor
  • public getInstance method that returns instance of the class


In this article we are going to check a few techniques how to make the first letter of a string Uppercase. This may be a popular interview question so let’s deep dive into many ways of achieving the same result.

First, let’s look at a few test strings together with expected results:

'here is a string'   ==> 'Here is a string'
'the New York Times' ==> 'The New York Times'
'...continued' ==> '...continued'

Simple yet working

One way to uppercase the first letter is basically to… uppercase the first letter of a string:

const s = 'here is a string';
const result = s[0].toUpperCase()…


Photo by Nick Hillier on Unsplash.

It is 2020 (or maybe2020.0000000000000004) and rounding numbers is still a problem in JavaScript. Actually, it’s a problem in computing in general.

Here is a definitive guide on how to do this properly using JavaScript. Read through once and remember forever!

Introduction

First of all, let’s understand why floating numbers have been, are, and will continue to be a problem in computing.

Each number is a sequence of bytes. For example, the decimal number 3 is binary 00000011. That’s basically how computers represent each number — with bytes (i.e. one byte is 8 bits: 0or1). If we take eight bytes, 00000000


What’s actually a magic number? Basically, magic number is a code, cipher or number that has some “magic”, obscure but important meaning. However, just from reading the source code it’s not clear what’s the meaning.

It’s like finding the Answer to the Ultimate Question of Life, the Universe, and Everything. The answer is: 42. Why 42? ¯\_(ツ)_/¯

Let’s go back to computer programming and imagine we get some code back:

const response = await API.request();if (response.code === 5) {
// DO SOMETHING
}

Here we can see a magic number. 5 means something but looking at the source code…


Quick introduction

Latin alphabet is widely used across the World. Its base for many European languages, including English. In fact, English alphabet basically it’s the same as ISO basic Latin alphabet and consists of 26 letters: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z.

However, all other non-English, Latin based alphabets will have some special letters. …

Arek Jaworski

Programming, project management and politics

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