Creating Custom Types in TypeScript

JavaScript is a weakly typed language, which means we don't usually think about types. Typescript is strongly typed, which means everything has a type.

Occasionally we want to make an object or the return of a function conform to a certain format. This is where we use custom types. Typescript allows us to define our own custom types, which we can then use in our code.

Everything You Need To Know About JavaScript Variables

One of the most important concepts in JavaScript, as with most programming languages, is the ability to define variables. A variable is a container of a value or data. Some types of variables can later be changed, based on the logic we use in our code. Let's take a look at how variables work in Javascript.

Defining Variables

There are two main types:

What Is Bubble Sort?

Why Should I Care?

Bubble sort is an excellent introduction to sorting algorithms.

It is also useful as a reference when we cover more complex search algorithms later.

Three Ways to Create Objects in JavaScript

Almost everything in Javascript is an object, whether it’s an array or a function. In this post, we’ll learn three different ways to create objects in JavaScript:

  1. Object Literals.
  2. New Keyword.
  3. Classes.
You may also like: Object-Oriented JavaScript: Objects, Encapsulation, and Abstraction (With Examples).

Object Literals

A JavaScript object literal is a comma-separated list of name-value pairs wrapped in curly braces. Object literals encapsulate data, enclosing it in a tidy package.

Validate Street Addresses With Vue.js and the HERE Geocoder Autocomplete API

When it comes to geocoding, being able to convert addresses to latitude and longitude coordinates so they can be displayed on a map is not the only use-case. A lot of times being able to geocode an address makes for great address validation to see if an address actually exists. Take for example a tutorial written by Jayson DeLancey titled, Street Address Form Validation with React.js and HERE Geocoder Autocomplete. In this tutorial, he demonstrated how to accept user input, offer suggestions, and ultimately check to see if the addresses are valid using React and the APIs found in the HERE Developer Portal.

We're going to change it up a bit. Instead of using React, we're going to try to validate addresses using Vue.js, another very popular framework for web development.

Creating a React Custom Element Wrapper Generator

A few days ago I published a post called “Wrapping React Components Inside Custom Element.” The post explained how to wrap a React component inside a custom element. At the end of the post, I wrote that I might think of a few ways to do the same functionality but automatic and more generic. In this post, I’ll explain one of those ideas.

Note: If you didn’t read the previous post, I suggest to read it to get some context for this post.

Observing Props

At first, I’ll take an assumption which is that the majority of React developers use the prop-types library to declare React prop types on their React component. Using this assumption, we can use the prop types to understand the names and the types of all the props that a component is receiving and to generate the observed attributes array for the custom element. We will create a getObserved helper function, which will be responsible to extract the names of the observed attributes from the prop types:

Code Organization in Functional Programming vs. Object Oriented Programming

Introduction

A co-worker asked about code organization in Functional Programming. He's working with a bunch of Java developers in Node for a single AWS Lambda, and they're using the same style of classes, various design patterns, and other Object Oriented Programming ways of organizing code. He wondered if they used Functional Programming via just pure functions, how would they organize it?

The OOP Way

If there is one thing I've learned about code organization, it's that everyone does it differently. The only accepted practice that seems to have any corroboration across languages is having a public interface for testing reasons. A public interface is anything that abstracts a lot of code that deals with internal details. It could be a public method for classes, a Facade or Factory design pattern, or functions from a module. All three will utilize many internal functions, but will only expose one function to use them. This can sometimes ensure as you add things and fix bugs, the consumers don't have to change their code when they update to your latest code. Side effects can still negatively affect this.

Var vs. Let in JavaScript

In this article, we wil be discussing the long running debate of var vs. let in JavaScript. We will also be discussing why the use of let is increasing in dev communities.

Var vs Let in JavaScript

Introduction

Declaring variables in JavaScript was not a cake walk until 2015 when ECMA 2015 was introduced and hence let and const was introduced and we got rid of var (it still works though!).

ADF Faces and Client-Side Value With innerHTML

In ADF Faces, you can leverage the full power of JavaScript. I will explain how you could assign a value from ADF Faces component to the plain HTML div.

The sample app is available on GitHub repo. It doesn't require DB connection, you can run it straight away in Oracle JDeveloper.

JavaScript Objects in Depth, Part 1: The Fundamentals

Introduction

JavaScript has two main data types: primitives and objects. The interesting thing here is that other than the primitive type everything else is an object, including functions. Therefore, if we are really interested in learning JavaScript, then understanding objects should be on the top in the list.

An object can be created with figure brackets ( {...})with an optional list of properties where a property is a key:value pair, where the key is a string and the value can be anything. By anything, we mean it can be a primitive or an object or even a function.

Java as a Technology Glue, or How to Use GPU From JavaScript

Ah! It’s been a while since I posted last!

But this year was quite a DE(VOXX)ED for me! First I had a chance to speak in wonderful Romania, then beautiful Vienna, after that amazing Lugano, then the loveliest Krakow, finally at the huge Antwerp event! In between, I also gave some talks in my hometown of Sofia at Java2Days and St. Petersburg at Joker! Let’s not forget that I was in the dream team of 5 to organize and run the coolest jPrime conf!

Working With ArrayDataProviders Using JavaScript Functions in Visual Builder

Storing data in ArrayDataProviders (rather than SDP) is useful whenever you want to further modify the data on the client side — for example, if you are looking to create updatable tables in your UI. A common follow up question is, "how can I do additional processing/updates on all the records I'm storing in the ADP?" This is what this post is about.

Since the records are now stored on the client-side, you can access them through JavaScript. You can, for example, write a page level module function to loop over the set of records and modify them. For example, in the video below I'm using this little function to raise the salary of all the employees:

How to Build a TCP Application With Node.js on ECS

Prerequisites

Before you start the process, you will need a machine running a Linux/Unix distribution such as Ubuntu or macOS, a code editor/IDE with Node.js installed on it and a basic working knowledge of Node.js.

Creating a TCP Server

To begin, create a directory where you would like to store your application. For this tutorial, we will create our application in ~/nodejs-tcp-app.

Distance Calculations Between Points With the HERE JavaScript SDK

When I'm interacting with developers using HERE APIs and services, one common question I get is around distance calculations. The HERE SDK and APIs make it easy to calculate paths or routes, but it isn't the most obvious if you want to pull the total distance from those calculations. In fact, there are multiple different distances that can be obtained.

As a developer, you could be searching for the distance between two points regardless of roadways. Take, for example, air travel or similar for that type of distance. You could also be searching for the distance between two points along a route that can be navigated. Think your GPS when you're driving or similar for that type of distance.

Real-Time Interaction Between Maps With Socket.io and JavaScript

I was doing some thinking recently. I was thinking about how I could make maps more useful than just displaying visual content on the screen when requested. While displaying map information on a screen is useful in many circumstances, it doesn't make for the most exciting of examples. This lead me to thinking about things from a more interactive level.

Take the example of first responders, such as law enforcement, fire, and medical. It might not make the most sense for them to be looking and refreshing a map to find incidents. Instead, what if the map automatically refreshed and was synchronized between the first responders? What I mean by this is, what if incidents automatically appeared on everyone's map at the same time without interaction?