DEV Community

Cover image for Dynamic typing in Javascript
aishwaryavasu0509
aishwaryavasu0509

Posted on

Dynamic typing in Javascript

what is dynamic typing ?

Dynamic typing

Javascript is a dynamic typing language. When you declare a variable, you do not need to specify what type this variable is. Javascript engine infers what type this variable is based on the value assigned to at run time.

example:

let name= "bob";
console.log(typoeof name);

name=5

console.log(typeof name);

firstly, the variable was a string and now it is of number datatype.
same thing can be done with null and undefined as well nd amongst any datatypes for that matter of fact.

Pros and Cons of Dynamic typing in JavaScript

Pros:

1.Deals naturally with certain types of self-describing data.
2.Code can be use polymorphically without programmer decoration.
3.Tends to reduce unnecessary clutter and duplication/repetition in code.

Cons:

1.More errors detected later in development and in maintenance.
2.More errors at runtime and in shipped code.
3.Tends to prohibit compilation and yields poor performing code.
4.Need to write entirely mechanical tests for type correctness.

Heroku

Amplify your impact where it matters most — building exceptional apps.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • 0:56 --last-failed: Zero in on just the tests that failed in your previous run
  • 2:34 --only-changed: Test only the spec files you've modified in git
  • 4:27 --repeat-each: Run tests multiple times to catch flaky behavior before it reaches production
  • 5:15 --forbid-only: Prevent accidental test.only commits from breaking your CI pipeline
  • 5:51 --ui --headed --workers 1: Debug visually with browser windows and sequential test execution

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Click on any timestamp above to jump directly to that section in the tutorial!

Watch Full Video 📹ī¸

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤ī¸