JavaScript : How Can We Use Javascript in Data Science?

Kaushik Denge
6 min readJun 25, 2021

JavaScript (js) is a light-weight object-oriented programming language which is used by several websites for scripting the web pages. It is an interpreted, full-fledged programming language that enables dynamic interactivity on websites when applied to an HTML document. It was introduced in the year 1995 for adding programs to the web pages in the Netscape Navigator browser. Since then, it has been adopted by all other graphical web browsers. With JavaScript, users can build modern web applications to interact directly without reloading the page every time. The traditional website uses js to provide several forms of interactivity and simplicity.

Features of JavaScript

Various features of JavaScript are as follows:

1. Client — Side Technology

JavaScript is a client-side technology. It is mainly used for giving client-side validation. It is an object-based scripting language.

2. Greater Control

It gives the user more control over the browser.

Example — You can change the background color of the page as well as text on the browser’s status bar.

Here, the back button is implemented with JavaScript. Click it and you will return to the page from which you have arrived.

3. Detecting the User’s Browser and OS.

The feature to detect the user’s browser and OS enables your script to perform platform–dependent operations.

4. Performing Simple Calculation on the Client side

Using a JavaScript calculator, we perform simple calculations on the client side.

5. Validating The User’s Input

In the JavaScript calculator, try to type some letters instead of numeric input, you will get an error: Invalid input character. Note that, JavaScript helps the browser perform output validation without wasting the user’s time by the web server access.

If the user makes a mistake in the input, the user will get an error message immediately. If the input information is validated only on the server, then the user would have to wait for the server’s response.

6. Handling Date and time

The JavaScript says, “Nice Morning, isn’t it? Or “Good Afternoon”, depending on the current time. It also tells you today’s date.

Nice Morning isn’t it? Today is Wednesday, 20 February 2019.

7. Generating HTML on the Fly

Every time you click on the button, the browser generates and displays a new HTML code. Thanks to JavaScript, this operation performs on the client- machine and therefore you don’t have to wait while the information backs and forth between your browser and the web server.

8. Semicolon Insertion

All statements in JavaScript must terminate with a semicolon. Most of the JavaScript control statements syntax is the same as control statements in C.

JavaScript Frameworks :

  • Vue.js is an open-source model-view-viewmodel front end Javascript framework for building user interfaces and single page applications. It was created by Evan You, and is maintained by him and the rest of the active core team members.
  • ReactJS is an open-source front-end JavaScript library for building user interface or UI components. It is maintained by Facebook and a community of individual developers and companies. React can be used as a base in the development of single-page or mobile applications. However, React is only concerned with state management and rendering that state to the DOM, so creating React applications usually requires the use of additional libraries for routing, as well as certain client-side functionality.
  • Ember.js is an open-source JavaScript web framework, utilizing a component-service patter. It allows developers to create scalable single-page web application by incorporating common idioms, best practices, and patterns from other single-page-app ecosystem patterns into the framework.
  • Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS is a JavaScript based open-source front-end web-framework mainly maintained by Google and by a community of individuals and corporations to address many of the challenges encountered in developing single-page-applications. It aims to simplify both the development and the testing of such applications by providing a framework for client-side model-view-controller (MVC) and model-view-viewmodel (MVVM) architectures, along with components commonly used in web applications and progressive web applications.

JavaScript in DATA SCIENCE :

JavaScript, the most popular language for web development. Apart from that, can we use it for Data Science? In this blog post, I will share the use of JavaScript in my data scientist job and how you can use it to help you.

We use JavaScript for visualizations, asynchronous tasks, and handling real-time data. We use D3.js to create beautiful and interactive charts for users to explore complex business data. We also use NodeJS plus SocketIO to handle real-time data. It might be counter-intuitive to use JavaScript as the language for data science tasks. JavaScript is playing a crucial part in entire data science workflow.

When does a data scientist use JavaScript ?

We use JavaScript for visualizations, asynchronous tasks, and handling real-time data. We use D3.js to create beautiful and interactive charts for users to explore complex business data. We also use NodeJS plus SocketIO to handle real-time data. It might be counter-intuitive to use JavaScript as the language for data science tasks. JavaScript is playing a crucial part in entire data science workflow.

Most data scientists still prefer to use Python / R for conventional data science tasks. With the recent rise in machine learning, libraries like Tensorflow are already available in JS (https://js.tensorflow.org/). Now we already build ML models in browsers.

Any real-world use case that JavaScript helps in data science workflow?

Let’s use medical as an example. You are developing wearable devices and you want to collect users activity data. JavaScript runs on almost all platforms including wearables. Using JavaScript reduces compatibility issues, and it enables data scientists to collect data from medical devices and run algorithms in a streamlined fashion.

Why JavaScript over different modes such as Python?

Unless you have decided that you want to learn data science first, then you may learn Python or R first. Otherwise, I recommend JavaScript over other languages for beginners and startups.

JavaScript’s learning curve is not as steep, as we can use JavaScript for both client-side and server-side programming. NodeJS is efficient because of its single threaded event call back mechanism. That enables us to develop scalable real-time applications.

It’s all about picking the right tool for the right tasks. Although Python has developed a robust ecosystem of data science tools that help data scientists perform analytical work.

I believe that in the future, JavaScript will develop an ecosystem of data science tools of its own flavor in the near future.

--

--