Hands-on JavaScript for Python Developers

Book description

Build robust full-stack web applications using two of the world's most popular programming languages Python and JavaScript

Key Features

  • Discover similarities and differences between JavaScript and Python coding conventions
  • Explore frontend web concepts, UI/UX techniques, and JavaScript frameworks to enhance your web development skills
  • Put your JS knowledge into practice by developing a full-stack web app with React and Express

Book Description

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.

What you will learn

  • Discover the differences between Python and JavaScript at both the syntactical and semantical level
  • Become well versed in implementing JavaScript in the frontend as well as the backend
  • Understand the separation of concerns while using Python programming for server-side development
  • Get to grips with frontend web development tasks, including UI/UX design, form validation, animations, and much more
  • Create modern interaction interfaces for your Python web application
  • Explore modern web technologies and libraries for building full-stack applications

Who this book is for

This book is for experienced Python programmers who are looking to expand their knowledge of frontend and backend web development with JavaScript. An understanding of data types, functions, and scope is necessary to get to grips with the concepts covered in the book. Familiarity with HTML and CSS, Document Object Model (DOM), and Flask or Django will help you to learn JavaScript easily.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-on JavaScript for Python Developers
  3. Dedication
  4. About Packt
    1. Why subscribe?
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  7. Section 1 - What is JavaScript? What is it not?
  8. The Entrance of JavaScript into Mainstream Programming
    1. Technical requirements
    2. NCSA and the need for interactivity
    3. Early web browsers and a 10-day prototype
    4. Enter Ecma International
    5. HTML, CSS, and JavaScript – the best friends of the frontend
    6. HTML, the overlooked hero
    7. CSS
    8. JavaScript
    9. How JavaScript fits into the frontend ecosystem
    10. Our first Ajax application
    11. JavaScript in practice
    12. Summary
    13. Questions
    14. Further reading
  9. Can We Use JavaScript Server-Side? Sure!
    1. Technical requirements
    2. Why use JavaScript on the server side?
    3. Grammatical similarities
    4. A bit more history
    5. The Node.js ecosystem
    6. Node.js
    7. npm
    8. Express.js
    9. Threading and asynchronicity
    10. Traditional client-server architecture
    11. Node.js architecture
    12. Summary
    13. Questions
    14. Further reading
  10. Nitty-Gritty Grammar
    1. Technical requirements
    2. A history of style
    3. Grammar rules
    4. Capitalization counts
    5. Reserved words
    6. Declaring variables
    7. const
    8. let
    9. var
    10. Data types
    11. typeof and equality
    12. Arrays and objects
    13. Conditionals
    14. Loops
    15. for loops
    16. while loops
    17. do/while loops
    18. for..in loops
    19. for..of loops
    20. Functions
    21. Function declarations
    22. Function expressions
    23. Arrow functions
    24. Comments
    25. Methods and properties
    26. Punctuation and readability
    27. The elephant in the room – whitespace
    28. Existing standards – linting to the rescue!
    29. Summary
    30. Questions
    31. Further reading
  11. Data and Your Friend, JSON
    1. Technical requirements
    2. Data types – both JavaScript and Python are dynamically typed!
    3. Exploring data types
    4. Booleans
    5. Numbers
    6. Strings
    7. Exercise – a basic calculator
    8. Arrays and sets
    9. Arrays 
    10. Sets
    11. Objects and JSON
    12. Prototypal inheritance
    13. JSON
    14. The HTTP verbs
    15. API calls from the frontend – Ajax
    16. SWAPI lab
    17. Summary
    18. Questions
    19. Further reading
  12. Section 2 - Using JavaScript on the Front-End
  13. Hello World! and Beyond: Your First Application
    1. Technical requirements
    2. I/O with the console and alert messages
    3. Working with input in a function
    4. Exercise – Fibonacci sequence
    5. Fibonacci sequence solution
    6. Using objects as a datastore
    7. Exercise – multiplication
    8. Multiplication solution
    9. Step 1 – computing and storing
    10. Step 2 – retrieval
    11. Understanding scope
    12. Scope chains and scope trees
    13. Closures
    14. A basic example of a closure in practice
    15. Summary
    16. Questions
    17. Further reading
  14. The Document Object Model (DOM)
    1. Technical requirements
    2. Using selectors
    3. DOM manipulation explained
    4. Using selectors
    5. Using other selectors
    6. Properties
    7. Manipulations
    8. Sticky note creator
    9. Solution code
    10. Summary
    11. Questions
    12. Further reading
  15. Events, Event-Driven Design, and APIs
    1. Technical requirements
    2. The event life cycle
    3. Capturing an event and reading its properties
    4. Sticky notes revisited
    5. Sticky notes – solution 1
    6. Sticky notes – solution 2 – event delegation
    7. Sticky notes – solution 3
    8. Using Ajax and events to populate API data
    9. Starter code
    10. Custom events
    11. Solution code
    12. Handling asynchronicity
    13. Error handling
    14. Star Wars API exploration Lab
    15. A solution
    16. Summary
    17. Questions
    18. Further reading
  16. Working with Frameworks and Libraries
    1. Technical requirements
    2. jQuery
    3. Advantages of jQuery
    4. Disadvantages of jQuery
    5. Examples of jQuery
    6. Angular
    7. Advantages of Angular
    8. Disadvantages of Angular
    9. Examples of Angular
    10. Single-page applications
    11. The JavaScript
    12. React and React Native
    13. Advantages of React
    14. Disadvantages of React
    15. Example of React 
    16. Components
    17. React Native
    18. Vue.js
    19. Features of Vue.js
    20. Example of Vue.js
    21. Summary
    22. Further reading
  17. Deciphering Error Messages and Performance Leaks
    1. Technical requirements
    2. The Error object
    3. Using debuggers and other tools
    4. Safari
    5. Internet Explorer and Microsoft Edge
    6. The JavaScript console
    7. Accommodating JavaScript's performance limitations
    8. The Memory panel
    9. Summary
    10. Questions
    11. Further reading
  18. JavaScript, Ruler of the Frontend
    1. Technical requirements
    2. Building interactions
    3. Using dynamic data
    4. Input validation and error handling
    5. Security and data
    6. Understanding modern applications
    7. Summary
  19. Section 3 - The Back-End: Node.js vs. Python
  20. What Is Node.js?
    1. Technical requirements
    2. History and usage
    3. Installation and usage
    4. Grammar and structure
    5. Customer lookup
    6. ASCII art and packages
    7. Hello, World!
    8. Pokéapi, revisited
    9. Summary
    10. Further reading
  21. Node.js versus Python
    1. Technical requirements
    2. Philosophical differences between Node.js and Python
    3. Performance implications
    4. Caveat emptor
    5. Summary
    6. Further reading
  22. Using Express
    1. Technical requirements
    2. The scaffold: Using express-generator
    3. RESTful architecture
    4. Routes and views
    5. Routes
    6. Saving data
    7. Delete
    8. Views
    9. Controllers and data: Using APIs in Express
    10. Creating an API with Express
    11. Challenge
    12. Ship properties
    13. Summary
    14. Further reading
  23. React with Django
    1. Technical requirements
    2. Django setup
    3. Prithee, upon what shall we toil? Speak!
    4. Routing our requests
    5. Creating the React frontend
    6. Bringing it all together
    7. Investigating the React frontend
    8. Summary
  24. Combining Node.js with the Frontend
    1. Technical requirements
    2. Understanding the architecture handshake
    3. The frontend and Node.js - React and image upload
    4. Architecture
    5. Investigating the React JSX
    6. Deciphering the Express application
    7. Creating a recipe book with APIs and JSON
    8. Setting up the application
    9. Testing the API
    10. Diving into the code
    11. Making a restaurant database with Yelp and Firebase
    12. The starting line - creating a React app
    13. Getting set up with Firebase
    14. Testing our database
    15. Creating our app
    16. Summary
  25. Enter Webpack
    1. Technical requirements
    2. The need for bundling and modules
    3. package.json
    4. Build pipelines
    5. Using webpack
    6. Deploying our project
    7. Chunking
    8. Surrender
    9. Deployment, finished
    10. Summary
  26. Section 4 - Communicating with Databases
  27. Security and Keys
    1. Technical requirements
    2. Authentication versus authorization
    3. Using Firebase
    4. .gitignore and environment variables for credentials
    5. Reorganizing our application
    6. Summary
  28. Node.js and MongoDB
    1. Technical requirements
    2. Using MongoDB
    3. Getting started
    4. Testing with Jest
    5. Storing and retrieving data
    6. Models, views, and controllers
    7. Wiring your API together
    8. Exporting functions
    9. Improving our program
    10. Security
    11. Summary
  29. Putting It All Together
    1. Technical requirements
    2. The project brief
    3. Scaffolding – React
    4. Functional components
    5. Next steps
    6. The backend – setting up our API
    7. API as a proxy – Step 3
    8. The database – all CRUD operations
    9. Summary
    10. Further reading
  30. Assessments
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 9
  31. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Hands-on JavaScript for Python Developers
  • Author(s): Sonyl Nagale
  • Release date: September 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781838648121