Course

Statically vs Dynamically Typed Languages

Loading...

Learning Objective: Differentiate between typed and typed languages in terms of data types.


What are typed languages?

  • Statically typed languages are those in which the type of each variable andexpression is determined at compile time.
  • Once a variable is assigned a specific data type, it cannot store values ofa different type.
  • Examples: C, C++, and Java.

What are typed languages?

  • Dynamically typed languages are those in which the type of each variable isdetermined at runtime.
  • Variables can store different data types at different times.
  • Javascript is dynamically typed language.

Change Variable Data Type

In JavaScript, you can change the data type of a variable at any time. For example, you can change a variable from a number to a string:

let age = 25;
console.log(age); // 25

age = "25";
console.log(age); // 25

Key Differences Between and Languages

Feature

Statically Typed

Dynamically Typed

Type CheckingPerformed at compile time.Performed at runtime.
FlexibilityLess flexible; variables have fixed types.More flexible; variables can change types.
Error DetectionCatches type-related errors before execution.Errors may appear only during execution.
PerformanceGenerally faster due to early type checks.Can be slower due to runtime type checking.
ExamplesC, C++, Java.JavaScript, Python, Ruby.

What’s Next?

In this lesson, you learned the difference between statically typed and dynamically typed languages. Now, let’s dive into Operators in JavaScript!

0 Comments

"Please login to view comments"

glass-bbok

Join the Conversation!

Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.

Upgrade your account
tick-guideNext Lesson

Variables and Data Types Interview