liveBook · Manning

Just

As explained in Functional Programming in JavaScript

A Maybe case that wraps a defined value.

Just is the Maybe case for a real, present value. It wraps the value so later steps can keep using the same safe container instead of handling raw null checks. section 5.3

In the Maybe pattern, Just pairs with Nothing: Just carries the value, while Nothing represents absence. A lookup can return either one, letting chained operations continue safely.

Safe lookup with Just

A student lookup can return Maybe(Student); when the record exists, mapping the address gives Just(Address(...)) instead of a null crash.

const findStudent = R.curry(function(db, ssn) {
   return wrap(find(db, ssn));                                  #1
});
const getAddress = function(student) {
   return wrap(student.fmap(R.prop('address')));                #2
}

Shows a wrapped lookup result that later composes with address extraction, making the safe flow concrete. section 5.3

How Functional Programming in JavaScript covers it

How deep it goes
Defines the Just subtype and shows its role in mapping and unwrapping, but leaves broader monad theory to later treatment.
Examples
Uses student lookup, address extraction, and a simple half function on wrapped numbers.
What it assumes
Assumes basic JavaScript functions and wrapping values in Maybe; introduces the Just case from the ground up.
What you can do after
Apply it to keep a successful value in a safe container through chained transformations.
How it connects
Connects to Maybe, Nothing, map, getOrElse, and fromNullable.

Also explained in

Compare how 2 books explain Just →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in JavaScript. The section links point to the parts of the book it draws on.