Image for post
Image for post

When we think of programming paradigms, the one that receives the most coverage is Object-Oriented Programming. This is to say, a programming paradigm is how code is implemented and executed, and in the case of OOP, it is via the use of classes and objects. However, aside from the OOP paradigm, the functional programming paradigm is one that is gaining popularity, as it is seen extensively within React and other libraries. JavaScript enables such a style because functions can be used as data, and passed around within a program. …


Image for post
Image for post

In JavaScript, anything that is not a primitive value such as strings or integers is an object. What this means is that functions are actually objects or at least specialized objects. This also means that functions have access to properties and methods like all other objects do. JavaScript defines built-in properties and methods on functions like the name property which returns the name of the function declaration or the variable name that binds to the function object within function expressions.

function thisFunc() {
...
}
console.log(thisFunc.name) // => thisFunc
const thatFunc = () => ...
console.log(thatFunc.name) // => thatFunc

Included…


Image for post
Image for post

To recap my last blog, “Exploring Closures with JavaScript Functions”, to understand closures, it’s essential to remember that functions create an enclosed environment known as a namespace. Namespaces allow you to work with variables that have been defined within other namespaces or scopes without overwriting them. Now here is the critical part, when a function is defined, the function object that is created not only contains the code defined within its code block but also a reference to the namespace it was defined in, and the variable bindings within the namespace.

function outerFunc() { const outerFuncScope = "outerFunc"; return ()…


Image for post
Image for post

Continuing with the theme of functions and their many lesser-known features, closures are one of the more important and powerful features to be aware of. In understanding them, we first have to start with the idea of a namespace, which is a space where variables bindings are made. These bindings are protected from any outer bindings that may share the same variable names and risk overwriting the bindings.

// global namespace
let scope = "global"; // first variable binding
if (true) { // if statement namespace
let scope = "local";
console.log(scope); // => local
}
console.log(scope); // => global

In…


Image for post
Image for post

In programming, functions are foundational. They modularized logic which creates reusability and cleaner code. Sometimes, functions are able to carry out their logic with outside input known as arguments. Arguments are then used within a function’s body to compute a return value. Functions are able to utilize arguments through function defined local variables called parameters. JavaScript functions also allow many ways to work with parameters and arguments, some of which are not too familiar.

When working with parameters and arguments, the simplest variation is a function that expects a single argument.

function greet(greeting) {
console.log(greeting);
}
greet("hello"); // => hello


Image for post
Image for post

In JavaScript, functions are objects which provide a modular way to define a set of procedures or operations that can be used many times within a program. By using functions, code is abstracted away reducing potential repetitive logic and helping to maintain legibility. But when working with functions, it is important to know a few things about them, like the fact that they have access to many values that affect how the function can be used. For example, a common value that functions have access to are parameters, which are used as local variables within the code block of the…


Image for post
Image for post

Working with data can take two forms, either some work is done directly to it resulting in the data being fundamentally changed or it can be copied, and then have some work done to the copy. Most, if not all of the time, working with data in an immutable way is the preferred way because it increases the efficiency of being able to follow the flow of data and the changes made to it. For example, the React library uses this concept of maintaining immutability when working with state. The state of a component, or the data that describes the…


Image for post
Image for post

Usually when we think of a data structure being iterable, we think of arrays and strings. JavaScript provides many ways to iterate over an array or string, ranging from the standard for-loop to more modern variation like the ES6 for/of loop. However, because objects are not inheritently iterable, JavaScript has defined the for/in loop which is specifically for iterating over objects. The for/in loop iterates over each property name or key in the object, by which then you could access the value. …


Image for post
Image for post

Objects are a fundamental data structure to any and all programming languages. They go by many names such as hashes, dictionaries, even associative arrays but what they really are is an unordered collection of properties or values that are retrieved by a name or key. In JavaScript, objects are reference data types, dynamic, can maintain their own properties but also can inherit properties from other objects. This brings us to the main idea, in JavaScript, objects follow what is known as “prototypal inheritance” which means that objects inherit from the prototype object of their constructor, also known as a class.


Image for post
Image for post

In the previous blog, Getting Started with WebSockets, I went over the initial configuration of the server set-up to change its behavior to allow bidirectional communication between it and the client. The configuration included the Socket.io library which handled the configuration of the server, priming the application to take advantage of websocket connections and real-time communication. Picking up from there, after the application is configured to maintain open and persistent connections between the server and client, we can begin to implement various communication between server and client, known as events. The first type of event is between the server and…

Uriel Rodriguez

Flatiron School alumni and Full Stack web developer.

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