Join us and get access to thousands of tutorials and a community of expert Pythonistas.
This lesson is for members only.Join us and get access to thousands of tutorials and a community of expert Pythonistas.
Python vs JavaScript for Python Developers (Summary)
This course was an introduction to JavaScript for Python programmers and covered a broad swath of JavaScript, especially concentrating on areas that would be unexpected for programmers coming from another language.
In this course, you learned:
- Where JavaScript comes from and where it is used
- How JavaScript’stype system is different from Python’s
- How to writefunctions in JavaScript
- The two ways of creatingobjects in JavaScript
- General language syntax in JavaScript
- Surprises and behaviors in JavaScript that Python programmers wouldn’t expect
Here are some resources for more information about JavaScript package managers:
00:00In the previous lesson, I finished the section on quirks by covering thethis keyword and how it is set based upon the calling context of a function. Inthis lesson,I’ll wrap everything up by summarizing what you’ve covered and briefly talkabout where to go next.
00:15I started out giving a brief history of how JavaScript came about and the placeswhere it can be run. I talked about types in JavaScript and how, unlike Python,there are two kinds: primitive and reference.
00:28I also spoke about how JavaScript supports autoboxing,changing primitive types into their corresponding reference objects on the flyas needed. After that,there was a lesson on functions in JavaScript, followed by onewhich delved into objects.
00:43Both the old way of using function-based constructorsand the new way of using classes was discussed.
00:51There were two lessons on the details of the syntax of JavaScript.These covered code blocks, ternary operators, statementsand semicolons, identifiers, comments,strings, variable scoping, theswitch statement,freezing objects and using them like enumerations, the arrow functionshortcut, using destructuring assignments, thewith statement,generators, and asynchronous functions using theasync andawaitkeywords. With the basic syntax down,I spent several lessons on the places where JavaScript’s behavior may not seemintuitive for those coming from other languages.
01:32A lot of these quirks are due to the fact that JavaScript has far surpassed itsoriginal purpose.Plenty of things have been added to the language to make it easier to use and tomake your code cleaner. Due to supporting backward compatibility, though,the original odd things are still in the language. Over the course of severallessons, I covered how arrays aren’t like arrays that you’re used to,how sorting an array is string-based by default,how semicolons being optional can bite you, the different kinds of loopingstructures,the lack of errors when calling a function-based constructor without thenewkeyword,howvar works with the global scope, within function scope, and with hoisting,how function signatures are merely a suggestion,how JavaScript’s automatic typecasting can cause unexpected results whencomparing different types, how numbers are all floatsexcept for the newBigInt, the fact that there are two kinds of empty,and finally, a long detailed lesson on how thethis keyword works.
02:36Learning the syntax of a language is only the beginning.Modern languages have a daunting learning curve due to all the libraries andtools out there. JavaScript is no different.
02:46There are two contexts for JavaScript usage: server-side using Node or within thebrowser. Although everything that I’ve covered works in the browser,it is only the tip of the iceberg. Within the browser,you’re going to want to make changes to the HTML in order to interact with theuser.
03:02This was the original purpose of JavaScript, and still its most common usage.Within a browser,there are a series of built-in functions for managing what the user sees.
03:11The HTML is mapped to the DOM, or Document Object Model—a model of what is being presented.You use the built-in functions to manipulate the DOM,thus interacting with the user. JavaScript on its own is quirk-errific,but JavaScript plus HTML plus CSS, both of which are quirky in their own right,and you’re entering the world of quirk-errendous.
03:34Whether that word I just made up is based on “tremendous” or “horrendous” issomething you’ll have to discover for yourself.
03:41If you’re using JavaScript for a bit of form validation,you can get away with just adding some files to your web server and serving themup. For large projects,you’re going to want to think about a tool chain for helping you manage yourcode. JavaScript has tools for package management like Bower, npm,and Yarn. There are testing frameworks such as Jasmine,Jest, and Mocha, and scaffolding tools such as cookiecutter and Yeoman.
04:05There’s also a whole world of frameworks in this space.They range from things like jQuery,which helps you manipulate the DOM and was originally builtso you didn’t have to remember differences in the various browserimplementations, to full single-page application frameworkssuch as Angular, React, and Vue. Angular isTypeScript-only, but as that is a superset of JavaScript,you can transition fairly easily. React is both JavaScript and TypeScript.
04:34Both Angular and React are fairly opinionated about how to build and manage yourcode. That can make for a steep learning curvebut it also means you’re more likely to be able to reuse other people’s pluggablecomponents. Vue is a lighter-weight framework. I’ve been using this one a lot asof late.
04:50A lot of the web development I do is in Django and I don’t usually write single-pageapplications. From page to page in my software,I need a varying degree of interactivity.
05:00As Vue is a bit less opinionated than Angular or React,I find it easier to drop in on those pages where I need more power, whilesticking to straight Django templating where I can.
05:12You’ve covered a lot and there’s still loads more out there.Thanks for sticking with me through it all.Whether you find yourself writing JavaScript or Python, happy coding!
Alain Rouleau onJune 27, 2021
Great introduction to JavaScript as it compares to Python. Lots of information packed into a short period of time, that’s for sure. But it really does give you a sense of how everything works. Thanks a lot and keep up the good work!
dudutt onJuly 12, 2021
Nice course! I like this kind of introduction with opinions and tips about what is preferred to use and what is more likely to go wrong. I’m learning Python and Javascript for a project, so I’ve felt like this course was made for me.
Marko onDec. 19, 2021
Your courses are highly informative and they are a great resource for students such as myself. If you find the time, please make a Python vs C# course!

Christopher TrudeauRP Team onDec. 20, 2021
Hi Marko,
Glad you found it useful. I’ve never done any C#, so somebody else at RP would have to take that on. I did see a Java article get posted recently:
James Walters onApril 6, 2022
Thanks Chris! Your dated references weren’t lost on me.
As someone who last attempted to pick up JavaScript sometime in the late 00’s and rage-quit after encountering the footgun of floating point arithmetic (I built a calculator:3 + 3 was6,+ 3 was9,+ 3 was11.98), this at least cast these various traps and pitfalls in terms I can understand, having learned Python in the last few months. This is the resource I’ll refer people to as JS newcomers coming from Python!

Christopher TrudeauRP Team onApril 7, 2022
Glad you enjoyed it. Floating point is messy everywhere, JS just makes it worse because strings can get involved.
Python REPL:
>>>0.1+0.20.30000000000000004What Python does do well is it has a module for fractions and decimals that can give you the precision you probably want.
See:
realpython.com/python-numbers/
and
Become a Member to join the conversation.
Course Contents

