#Day28 - From Python to JavaScript - The Basics Part 1
Tags: javascript, python, programming, 100daysofcode
Published: 2021-04-17 23:00:11

I have worked with JavaScript previously but it's been almost 3 years since I have written any JavaScript Code. I have mostly been working with Python and I am all for Python. However, there is no denying that JavaScript is everywhere like EVERYWHERE. As I am re-learning JavaScript, I am going to document my experiences, in case anyone is in a similar boat (Learning JavaScript as a Python Developer). 

We will be covering the following in this tutorial
- Why you should learn JavaScript
- How to Run JavaScript/Python and show output
- Variables
- Comments

### Why JavaScript?
{% twitter 1375465851198046217 %}

I have borrowed a Tweet from [Danny Thompson](https://twitter.com/DThompsonDev) and as you can see JavaScript is used almost everywhere. Although, not the most popular choice, it can be used for building Machine Learning Models as well.
Additionally, it can also be used to build various bots for Twitter, Discord, LinkedIn, etc

### How to run JavaScript/Python
The Easiest Way? Use an online tool like [Replit](https://replit.com/). It supports both JavScript(Select NodeJS) and Python.

#### Python
We can use the terminal to run Python files.
```bash
python main.py
```
To display an output, we can use the print function
```python
print("Hello World!")
```

#### Javascript
Either you can link a javascript file in an HTML file and open it using any modern browser. Or you could open your <a href="https://balsamiq.com/support/faqs/browserconsole/#:~:text=To%20open%20the%20developer%20console,(on%20Windows%2FLinux ">browser's developer tools</a>

To display an output, we can use console.log()
```javascript
console.log("Hello World!")
```

### Variables
We will only consider the basic variables, i.e we won't be considering Lists, Tuples, Dictionaries, etc. We will discuss Lists, Tuples, etc in future articles.

#### Python

We use the following syntax to declare a variable in Python
```python
variableName = value
```

In Python, we have the following basic variable types
- Integers
```python
variable_integer = 10
```
- Float
```python
variable_float = 9.8
```
- Boolean
```python
variable_boolean = True
```
- String
```python
variable_string = "HelloWorld"
```
- Although Python doesn't support constants, there is a naming convention to declare constants. Constants are named in all upper case letters
```python
PI = 3.14
```
- Python also supports None values.
```python
variable_None = None
```

#### JavaScript
There are a couple of ways to declare variables in JavaScript. JavaScript also supports constants but we will discuss that in a bit.
```javascript
let variableName = value
var variableName = value
```
The keyword "let" is preferred over "var". Below are the basic data types in JavaScript
- Numbers
```javascript
let variable_number_integer = 10
let variable_number_float = 9.8
```
Unlike Python, JavaScript doesn't differentiate between float and integers.

- Boolean
```javascript
let variable_booelan = true
```

- Strings
```javascript
let variable_string = "HelloWorld"
```

- Unlike Python, JavaScript supports constants. They are immutable.
```javascript
const PI = 3.14
```
- Additionally, JavaScript also supports the types NULL and Undefined
```javascript
let variable_null = null
let variable_undefined = undefined
```
The null type in JavaScript is similar to the None type in Python

### Comments
#### Python
- Single-Line Comments
```python
# This is a single line comment
```
- Multi-Line Comments
```python
'''
This is a multi-line comment
This is a multi-line comment
'''
```

#### JavaScript
- Single-Line Comments
```javascript
// This is a single line comment
```
- Multi-Line Comments
```javascript
/*
This is a multi-line comment
This is a multi-line comment
*/
```

### Summary

![Screen Shot 2021-04-17 at 6.39.18 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1618699179638/e7yIZqbp_.png)