Book Image

Hands-on JavaScript for Python Developers

By : Sonyl Nagale
Book Image

Hands-on JavaScript for Python Developers

By: Sonyl Nagale

Overview of this book

Knowledge of Python is a great foundation for learning other languages. This book will help you advance in your software engineering career by leveraging your Python programming skills to learn JavaScript and apply its unique features not only for frontend web development but also for streamlining work on the backend. Starting with the basics of JavaScript, you’ll cover its syntax, its use in the browser, and its frameworks and libraries. From working with user interactions and ingesting data from APIs through to creating APIs with Node.js, this book will help you get up and running with JavaScript using hands-on exercises, code snippets, and detailed descriptions of JavaScript implementation and benefits. To understand the use of JavaScript in the backend, you’ll explore Node.js and discover how it communicates with databases. As you advance, you’ll get to grips with creating your own RESTful APIs and connecting the frontend and backend for holistic full-stack development knowledge. By the end of this Python JavaScript book, you’ll have the knowledge you need to write full-fledged web applications from start to finish. You’ll have also gained hands-on experience of working through several projects, which will help you advance in your career as a JavaScript developer.
Table of Contents (26 chapters)
Section 1 - What is JavaScript? What is it not?
Section 2 - Using JavaScript on the Front-End
Section 3 - The Back-End: Node.js vs. Python
Section 4 - Communicating with Databases

The Error object

Let's take a look at Open the index.html file and examine the JavaScript console. The first function, typoError, is invoked and throws a wonderful error.

It should look like this:

Figure 9.1 - Error console

Now, let's look at the code for our function in index.js:

const typoError = () => {
cnosole.error('my fault')

OK! It's a simple typo, as we've all done: it should be console.error instead of cnosole.error. If you've never made a typo in code… you're a unicorn. The error message we see in the console makes it easy to see what the error is and on what line of code it lives: line 2. Now, something interesting to note is that after calling typoError() toward the end of the file, we also have an invocation to another function but it doesn't fire. We know this because (spoiler alert) it also throws errors...