Python VS Javascript
Tags: python, javascript
Published: 2019-03-20 17:46:09

---
title: Python VS Javascript
published: True
description: 11 Comparison between Python and Javascript...
tags: #python, #javascript
cover_image: https://thepracticaldev.s3.amazonaws.com/i/wu0kj5r05mhfnano70d5.png
---
## 1. REPL (Read Eval Print Loop)
<ul>
<li>Python:</li>
<p>You’ll get it with the installation of python and call different python versions depending on the installation.</p>
<li>JavaScript:</li>
<p>Javascript doesn’t have inbuilt REPL as most of the time developers run in a browser, but you can use REPL by installing node.js.</p>
</ul>

## 2. Mutability
<ul>
<li>Python:</li>
<p>Python has mutable and immutable data types like set (mutable) and list (immutable).</p>
<li>JavaScript:</li>
<p>Javascript has no concept of mutable and immutable.</p>
</ul>

## 3. Strings
<ul>
<li>Python:</li>
<p>In python source code is ASCII by default unless you specify any encoding format.</p>
<li>JavaScript:</li>
<p>Javascript should be encoded as UTF-16 and no built-in support for manipulating raw bytes.</p>
</ul>

## 4. Numbers
<ul>
<li>Python:</li>
<p>In python, you’ve different numeric types like integer (int), float, fixed-point decimal, etc.</p>
<li>JavaScript:</li>
<p>Javascript has only floating point numbers only.</p>
</ul>

## 5. Hash tables
<ul>
<li>Python:</li>
<p>Python has built-in hash tables, called dictionaries, sets, etc, which can be used in hashing with keys and values.</p>
<li>JavaScript:</li>
<p>Javascript has no built-in hash table support.</p>
</ul>

## 6. Inheritance
Python:
Python uses class-based inheritance model.
![inheritance in python] (https://thepracticaldev.s3.amazonaws.com/i/dw8yberhuon4qppfhs77.jpg)
The example above shows you a class definition and __init__ function is a constructor.

JavaScript:
Javascript uses prototype based inheritance model.
![inheritance in javascript] (https://thepracticaldev.s3.amazonaws.com/i/v9ly33jdaouppafwlpbd.jpg)


## 7. Code Blocks
<ul>
<li>Python:</li>
Python uses indentation.
<li>JavaScript:</li>
Javascript uses curly brackets.
</ul>

## 8. Function Arguments
<ul>
<li>Python:</li>
Python will raise an exception if a function is called with incorrect parameters and accepts some additional parameter passing syntax.
<li>JavaScript:</li>
Javascript doesn’t care whether functions called with exact parameters are not as by default any missing parameter gets a value as “undefined” and any extra arguments end as special arguments.
</ul>

## 9. Data types
<ul>
<li>Python:</li>
Python has two similar data types list and tuple. Python list and javascript array are quite similar.
<li>JavaScript:</li>
Javascript has inbuilt array type.
</ul>

## 10. Properties and Attributes
<ul>
<li>Python:</li>
Python allows to define an attribute using descriptor protocol where you can use a getter, setter functions.
<li>JavaScript</li>
Javascript objects have properties which can be composed of underlying attributes and it let’s you define a property.
</ul>

## 11. Modules
<ul>
<li>Python:</li>
Python calls itself as a batteries included language as it comes with a wide range of modules.
<li>JavaScript:</li>
Javascript comes with very few modules like date, math, regexp, JSON and it has the functionality available through host environment like a web browser or other environment.
</ul>

Join my [telegram channel] (https://t.me/theprogrammersclub)