1

Must you define a data type when declaring a variable in JavaScript?

qfwfq
  • 2,416
  • 1
  • 17
  • 30

3 Answers3

0

No, you ca go with just

var x = 5;

The interpreter would guess what type the var is.

Terminus
  • 925
  • 10
  • 23
0

No. Javascript is not strongly typed.

sbartell
  • 883
  • 1
  • 7
  • 18
0

No, in Javascript variables are defined by simply using the var keyword followed by your variable name.

Example

var intVariable = 3;

var stringVariable = "Dog";

You can read more about javascript variables here

kalenpw
  • 695
  • 3
  • 10
  • 34