Skip to Content
Mastering JavaScript Functional Programming
book

Mastering JavaScript Functional Programming

by Federico Kereki
November 2017
Intermediate to advanced
386 pages
9h 22m
English
Packt Publishing
Content preview from Mastering JavaScript Functional Programming

Working with lists

Let's consider a simple procedure: suppose you have a list, and you want to add a new element to it. How would you do it? We can assume each node is a NodeList object.

class ListNode {   constructor(value, next = null) {       this.value = value;       this.next = next;   }}

A possible list would be as follows, where a list variable would point to the first element. See figure 10.1:

Figure 10.1. The initial list. (Can you tell what is missing in this list, and where?)

If you wanted to add D between B and F (this is something musicians will understand: we have here the Circle of Thirds, but D is missing) the simplest solution would be to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering JavaScript Functional Programming - Second Edition

Mastering JavaScript Functional Programming - Second Edition

Federico Kereki

Publisher Resources

ISBN: 9781787287440Supplemental Content