David Beazley1 thought that āJavaScript versus Data Scienceā would be a better title for this book. While that one word sums up how many people view the language, we hope we can convince you that modern JavaScript is usable as well as useful. Scientists and engineers are who we were thinking of when we wrote this book but we hope that these lessons will also help librarians, digital humanists, and everyone else who uses computing in their research.
We will cover:
⢠Core features of modern JavaScript
⢠Programming with callbacks and promises
⢠Creating objects and classes
⢠Writing HTML and CSS
⢠Creating interactive pages with React
⢠Building data services
⢠Testing
⢠Data visualization
⢠Combining everything to create a three-tier web application
Unlike most introductions to JavaScript, these lessons present an even mix of browser programming and server programming. We give each topic only shallow coverage; if you want to know more, there are many other free tutorials you can dive into once youāve mastered the basics, some of which are both up-to-date and well designed.
Every lesson should aim to meet the needs of specific learners2 [Wils2019]. The three people described below define the intended audience for this one.
Bhadra received a BSc in microbiology five years ago, and has worked since then for a biotech firm with labs in four countries. She did a statistics class using R as an undergrad, then learned some more R and some Unix shell scripting in a Software Carpentry3 workshop, but has no other training as a programmer. Bhadraās team is developing tools to detect structural similarities between proteins. They would like to build a browser interface to their tools so that people can test different algorithms on various datasets. This book will show Bhadra how to build, test, and deploy that interface.
Efraim did fieldwork for the Ministry of Natural Resources for thirty-one years. He learned Visual Basic so that he could write Excel macros, then mastered C in order to maintain the control software for some second-hand remote sensing equipment. Efraim recently retired, and is now an active member of several citizen science projects. This book will show him how to create a service to share those projectsā data with the world, and how to build a web-based administrative interface for it.
Sumi is completing a PhD in 19th Century history. As part of her research, she is transcribing and cataloging the records of several dozen Japanese-American midwives. She has been creating and customizing WordPress sites for several years, and has picked up bits and pieces of JavaScript while doing so. Sumi is about to start looking for a job, and wants to create an interactive website to showcase her research. This book will fill in some of the gaps in her knowledge and show her how to take advantage of JavaScriptās more modern features.
These prototypical users:
⢠can write two-page programs that use lists, loops, conditionals, and functions,
⢠can run commands in the Unix shell to navigate the filesystem and create and delete directories and files, and
⢠have reliable access to the Internet.
Maya Gans is a freelance data scientist and front-end developer by way of quantitative biology. She has 4 years of experience programming in R, and her passion for data visualization brought her to the weird world of JavaScript. When she isnāt debugging or blogging4 about code, sheās somewhere remote climbing large mountains. She dedicates this book to her fellow self-taught programmers who were told they werenāt good enough but are too driven and excited to care.
Toby Hodges5 is a bioinformatician turned community coordinator, working on the Bio-IT Project6 at EMBL7. He teaches a lot of courses in computing, organizes a lot of community-building events, listens to a lot of punk rock, and occasionally still finds time to write code and ride his bike. Toby would like to thank his wife for her support and patience while he swore about how annoying JavaScript is to debug.
Greg Wilson8 has worked for 35 years in both industry and academia, and is the author or editor of several books on computing and two for children. He co-founded Software Carpentry9, a non-profit organization that teaches basic computing skills to researchers, and is now part of the education team at RStudio10. Greg would like to thank everyone at Rangle11 who was so patient with him when he was learning JavaScript.
You can find the examples for each chapter in the src directory in our GitHub repository12. Each sub-folder contains the code and data needed to follow along with the text.
The exercises at the end of each chapter include new information that you will need later in the book, and are therefore not optional. You can do the first few online, using a service like RunKit13, which gives you an interactive JavaScript playground in your browser. For larger things, and for chapters starting with the one on creating dynamic web pages (Chapter 7), you should download and install14 the latest Longterm Support (LTS) versions of Node and NPM.
Node is an open source implementation of JavaScript that includes a command-line interpret...