The benefits of JavaScript for data analysis

As data goes everywhere, data analysts need a language that can come along for the ride. JavaScript is the future for data analysis, because it's ubiquitous, compatible, and has incredible support from the developer community.

The “data analysis problem" asks: How can we automate basic analysis and simultaneously empower users to create great analysis? Plenty of tools, like Excel, Tableau, Looker, Qlik, have tried to solve for this.

However, all these tools (and more) have the same problem: creative limitation. You can't fully automate an analysis if you are hamstrung by the ability to customize. And when you have to spend time doing manual updates, you can't focus on doing the great analysis. With a JavaScript-focused analysis tool, data analysts don’t face that limitation.

Here are some thoughts on why JavaScript is the future language for data analysts.


# 1: With JavaScript, you can 'use the camera' you have

(yes, you already have JavaScript)JavaScript is the language that is used to build the web. It’s ubiquitous. In Towards Data Science, Observable's Co-Founder and CTO Mike Bostock made this comparison: over the demise of cameras in favor of camera-equipped mobile phones, Photographer Chase Jarvis said, “The best camera is the one that’s with you.” Meaning: your cellphone camera is convenient, and in your pocket. It’s better than the camera left at home.Similarly, JavaScript is everywhere. Bostock explains, “Because JavaScript is the language of the web, it runs everywhere. Like the camera phone in your pocket, nearly everyone has a browser that runs JavaScript — the very browser you’re using to read this article. JavaScript enables interactive visualizationsexplorable explanationslive analysesmodel simulationscomputational artgamesquizzes, you name it… When someone shares an analysis implemented in JavaScript, you’re not just seeing a static snapshot of their work; you’re running it live in your browser. You can go beyond passive reading by querying data, tweaking assumptions, and asking questions.”

# 2: JavaScript lets you analyze data in a universal language

JavaScript is a universal language, in that it’s used across the world. That means that it’s easy for anyone who is familiar with JavaScript to get your analysis up and running on their laptop, tablet, or phone. It’s a language that is built for sharing, with no local installation required. And if you have a browser, you have JavaScript.

The image below is pulled from Observable notebook above, Visualizing Air Raid Sirens in Ukraine, was created by Volodymyr Agafonkin.

In this example, the benefits of using JavaScript for his data analysis were many. He was able to do all his data work in one place: the analysis, visualization, and presentation. In addition, he was able to share it out, to embed it anywhere, seamlessly.

air raid sirens

In fact, his notebook ended up being featured in the Washington Post newsletter entitled How To Read This ChartThe image below was pulled from that newsletter. Columnist Philip Bump used Agafonkin’s notebook to create and embed several unique visualizations in his article. Which leads us to the third way JavaScript makes data analysis faster and easier...

# 3: JavaScript lets you embed your data analysis anywhere

The image below shows Volodomir's embedded analysis in a Washington Post newsletter.

How to read this chart

Doing data analysis in JavaScript allows you to quickly embed your analysis in front-end applications (what any user sees and interacts with on a website). This allows you to reach a broader audience, and have more impact.For example, in a JavaScript-based tool like Observable, you can import, clean, and explore your data. Then, in that same platform, you can use ready-made snippets (for JavaScript novices) or code in JavaScript itself (for those who are fluent) to create your visualizations.Doing data analysis in JavaScript allows you to quickly share your results where your users are: in the browser. And an added benefit when you’re working in the platform you’re also sharing, changes you make to your work appear live to your user, so no more “please open this fixed version of the report” emails. Where your users go, they will see the latest and greatest.For example, in a JavaScript-based tool like Observable, you can do all your analysis work in the browser and when you’re ready to share, embed the results in any website with a simple HTML iframe. Did you forget to filter the outliers in your dataset? No problem, just update the analysis and your new work will be immediately live to your users. Does someone want to feature your great analysis on their blog? Great, you can share with them the same embed link and your work gets in front of more people with no additional cost.

# 4: You can use JavaScript libraries to work fast (and efficiently)

If you’re a data analyst who is newer to the world of coding, know this: there is plenty of pre-written code that helps you accelerate your learning. For example, a library of pre-written JavaScript code allows for easier development of JavaScript-based applications, and there are literally thousands of these libraries all publicly available, aka NPM modules.

It’s the same as with Python, where many popular data science libraries are found, and while JavaScript has been historically focused more on front-end web development, you’ll find that more and more developers are adding great data analysis and data science libraries

For many years already, some of the best visualization libraries are in JavaScript, like D3.js, Vega, Highcharts, Three.js, etc. and that’s because newsrooms, where we find many of the industry-leading visualization examples, are all web based.

That dynamic has created a plethora of JavaScript visualization libraries that are open-source, well maintained, and incredibly extensive. And that’s why you’re seeing more and more JavaScript libraries coming out that do data analysis and data science – analysts, developers, data scientists would rather work in one language, than doing analysis work in Python and visualization work in JavaScript.

To get started with a data analysis and visualization tool that uses JavaScript (as well as SQL, snippets, and more), try Observable for free.