Thứ Năm, Tháng Năm 19, 2022
  • Home
  • Health
  • News
  • Software
  • Tech
  • Travel
  • Gen Z
NATuts
  • Home
  • Health
  • News
  • Software
  • Tech
  • Travel
  • Gen Z
No Result
View All Result
NATuts
  • Home
  • Health
  • News
  • Software
  • Tech
  • Travel
  • Gen Z
No Result
View All Result
NATuts
No Result
View All Result
Home Tech

Why should you learn JavaScript and Python in 2022?

31 Tháng Một, 2022
in Tech
0
Why should you learn JavaScript and Python in 2022?
585
SHARES
3.2k
VIEWS
Share on FacebookShare on Twitter

Các bài viết liên quan:

Download TrunCad 2021 – Detailed installation instructions step by step

Download TrunCad 2021 – Detailed installation instructions step by step

18 Tháng Năm, 2022
4 sao gần biển lãng mạn

4 sao gần biển lãng mạn

18 Tháng Năm, 2022
Routes from Finland and Sweden to NATO

Routes from Finland and Sweden to NATO

18 Tháng Năm, 2022
How to Create a Vietcombank Account with a Free Phone Number

How to Create a Vietcombank Account with a Free Phone Number

18 Tháng Năm, 2022
12 Best Private Instagram Viewers in 2022 [No Human Verification]

12 Best Private Instagram Viewers in 2022 [No Human Verification]

18 Tháng Năm, 2022
Environmental pollution images

Environmental pollution images

18 Tháng Năm, 2022

A new year brings new opportunities for developers and those trying to learn to code. One of the most common dilemmas these people face is figuring out how and where to go when learning a new programming language from scratch. There are countless options and many different paths you can take.

Why should you learn JavaScript and Python in 2022?

Arguably two of the most popular and talked about programming languages ​​in the world are JavaScript and Python. If you search for JavaScript and Python jobs on any job platform, you’re likely to see hundreds, if not thousands, of results. The market is and will always be hot for these two languages ​​and that is not going to change any time soon. Both languages ​​also have some similarities. Both are C-based languages, which basically means they have general purpose, functions, and other logics.

Why should you learn JavaScript and Python in 2022?

Dynamic and Static

One of the highlights is that JavaScript and Python are dynamic languages. In a sense, a dynamic programming language does not require variables to be explicitly declared before using them. And vice versa, a static programming language will have to declare the data type when creating the variable. All of this will become clearer in the examples below.

Java example:

String myName; // Biến không có kiểu
myName = "Tony Stark"; // Biến có kiểu chuỗi
myName = 24; // Biến đã tự động thay đổi kiểu của nó thành số

If you run this Java code, you will get a compile error or a runtime error. Other data types cannot be assigned to variables. You can just use another string like “Steve Rogers”.

JavaScript example:

let myName; // Biến không có kiểu 
myName = "Tony Stark"; // Biến có kiểu chuỗi 
myName = 24; // Biến đã tự động thay đổi kiểu của nó thành số

Now if you run this JavaScript code, you won’t get an error because it’s perfectly valid. The value of the variable is now the number 24.

Python example:

my_name = "Tony Stark" # Biến có kiểu chuỗi
my_name = 24 # Biến đã tự động thay đổi kiểu của nó thành int

Similarly if you run this Python code, you won’t get an error because it’s perfectly valid. The value of the current variable is Int 24.

Data types

Data types are basically ways to store data inside an application. The data types specify what can be stored and how it can be managed. Below you will see a list of some of the data types that each language has.

JavaScript data types:

  • String type: string
  • Number type: number
  • Boolean type: boolean
  • Mapping type: object
  • Sequence type: array

Python data types:

  • String type: string
  • Numeric types: int, float, complex
  • Boolean type: boolean
  • Mapping type: dict
  • Sequence type: list, tuple, range

Syntax comparison

Next, we’ll compare the syntax of both programming languages ​​so you can see how easy it is to switch between the two. First, we will learn some of the differences between the two languages.

JavaScript

  • Use semicolon
  • Use curly braces for code blocks
  • Use the CamelCase naming convention for variables, e.g. firstName
  • Use console.log to output console messages

Functions that use this syntax:

function myFunc() {
    console.log('Hello World');
}

const myFunc2 = () => {
    console.log('Hello World 2');
};

myFunc();

myFunc2();

Python

  • Do not use semicolons
  • Do not use curly braces
  • Use the Snake Case naming convention for instance variables first_name
  • Use indentation for code blocks
  • Use print to output the message to the console

Functions that use this syntax:

def my_func():
    print('Hello World')

my_func()

String type

Both languages ​​output a variable of type string

JavaScript syntax:

let myName = "Tony Stark";
console.log(typeof myName); // string

Python syntax:

my_name = "Tony Stark"
print(type(my_name)) # str

Number type

In this example, both variables output a number.

JavaScript syntax:

let num = 9000;
let num2 = 9.0;
console.log(typeof num); // Number
console.log(typeof num2); // Number

Python syntax:

In this example, Python has a difference between a number and a real number because they are built in different data types.

num = 9000
num_2 = 9.0
print(type(num)) # Int
print(type(num_2)) # Float

Boolean style

The output is almost identical, the only difference is that JavaScript uses lowercase “t” for true while Python uses uppercase “T”.

JavaScript Syntax

let wizard = true;
console.log(wizard); // boolean

Python syntax

wizard = True
print(wizard) # bool

Mapping style

JavaScript uses object data structure while Python uses dictionary data structure. From looking at the examples, you can see that they are very similar. The difference is that JavaScript doesn’t require quotes for keys while Python requires them for keys in key value pairs.

JavaScript Syntax

const myprofile = {
    name: 'Tony Stark',
    age: 48,
    superhero: 'Iron Man',
};

console.log(myprofile);

Python syntax

my_profile = {
    "name": "Tony Stark",
    "age": 48,
    "superhero": "Iron Man",
};

print(my_profile);

Sequence style

JavaScript uses Array which is an object data structure type while Python uses a list data structure – a list. As you can see they have many syntactical similarities.

JavaScript Syntax

const myArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
console.log(typeof myArr); // object

Python syntax

myArr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print(type(myArr)) # list

Also, if you want to learn python then you can read this paragraph.

Previous Post

North Korean hackers return with stealthy variant of KONNI RAT . malware

Next Post

Autofill image attributes based on title for Blog » Fun Facts

Admin Natuts

Admin Natuts

Related Posts

How to Create a Vietcombank Account with a Free Phone Number

How to Create a Vietcombank Account with a Free Phone Number

18 Tháng Năm, 2022
12 Best Private Instagram Viewers in 2022 [No Human Verification]

12 Best Private Instagram Viewers in 2022 [No Human Verification]

18 Tháng Năm, 2022
Environmental pollution images

Environmental pollution images

18 Tháng Năm, 2022
What is Affiliate Marketing?  Terms to know in Affiliate

What is Affiliate Marketing? Terms to know in Affiliate

18 Tháng Năm, 2022
Information about the Kubet disc shock hack tool that players need to know

Information about the Kubet disc shock hack tool that players need to know

17 Tháng Năm, 2022
How to Screen Share on Google Duo on Android and the Web

How to Screen Share on Google Duo on Android and the Web

17 Tháng Năm, 2022
Load More
Next Post
Autofill image attributes based on title for Blog » Fun Facts

Autofill image attributes based on title for Blog » Fun Facts

Trả lời Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Bài viết mới

Download TrunCad 2021 – Detailed installation instructions step by step
Software

Download TrunCad 2021 – Detailed installation instructions step by step

18 Tháng Năm, 2022
4 sao gần biển lãng mạn
Travel

4 sao gần biển lãng mạn

18 Tháng Năm, 2022
Routes from Finland and Sweden to NATO
News

Routes from Finland and Sweden to NATO

18 Tháng Năm, 2022
How to Create a Vietcombank Account with a Free Phone Number
Tech

How to Create a Vietcombank Account with a Free Phone Number

18 Tháng Năm, 2022
12 Best Private Instagram Viewers in 2022 [No Human Verification]
Tech

12 Best Private Instagram Viewers in 2022 [No Human Verification]

18 Tháng Năm, 2022
Environmental pollution images
Tech

Environmental pollution images

18 Tháng Năm, 2022
W3Schools

Ads

Contact: [email protected]

DMCA.com Protection Status

Categories

  • Android
  • Cạm bẫy tâm lí
  • Chưa được phân loại
  • Đồ họa
  • Đời sống
  • Gen Z
  • Health
  • iOS
  • Kĩ năng mềm
  • News
  • Nhà mạng
  • Phần mềm
  • Phần mềm đồ họa
  • Review sách
  • Software
  • Tech
  • Thiết kế ảnh
  • Thiết kế video
  • Thủ thuật
  • Travel
  • Văn hóa Nam Bộ
  • Văn học
  • Window

Browse by Tag

ai là triệu phú android Apple browser Bullet Journal bản thân Chỉnh ảnh data domain download du lịch fshare game game show hosting HÌNH XĂM IKEA ios khuyến mãi kinh doanh kiến thức kiểm tra pin lừa đảo messenger miễn phí mua sắm Máy ảnh mạng mồi tiềm thức network nghệ thuật nhà Trần quảng cáo review tháp phân tầng xã hội tiếng anh tiện ích Trần Thủ Độ tên miền từ vựng viettel word xã hội Đơn giản đánh bạc

Recent News

Download TrunCad 2021 – Detailed installation instructions step by step

Download TrunCad 2021 – Detailed installation instructions step by step

18 Tháng Năm, 2022
4 sao gần biển lãng mạn

4 sao gần biển lãng mạn

18 Tháng Năm, 2022

Trang tin nóng hổi - vừa thổi vừa xem

No Result
View All Result
  • Home
  • Health
  • News
  • Software
  • Tech
  • Travel
  • Gen Z

Trang tin nóng hổi - vừa thổi vừa xem