+ 12

Do you need to declare variable data type in js?

This question was in challenge and answer was "no". WHY??? If you wont define a type you cant use it... Edit: Oh I was cheated, I do not use it, so it do not have to be declared!

25th Apr 2019, 8:22 PM
Sławek J.
10 Respuestas
+ 5
JavaScript is a loosely typed language, meaning you don't have to declare the data type when declaring a variable, as you might with other languages. A variable can hold any type of data without being specified. Here's an article you might find useful that goes into more detail: https://medium.com/@xiaoyunyang/javascript-is-a-loosely-typed-language-meaning-you-dont-have-to-specify-what-type-of-information-137408d54fc7
25th Apr 2019, 8:25 PM
Austin
+ 5
I think they use the term dynamically typed for languages where you don't have to declare the variable type.
26th Apr 2019, 8:32 AM
Sonic
Sonic - avatar
+ 3
Variable are dynamically allocated. So there are no data types such as Float, Double etc but in js there is string, number, Boolean. To declare a variable you just use the keyword var or let and the program will decipher if the value is a string or number or boolean on its own.
27th Apr 2019, 12:13 PM
Mufungo Geeks
Mufungo Geeks - avatar
+ 1
No, you don't need to declare variable type in js, it's dynamically determined.
26th Apr 2019, 12:43 PM
Vishnu DxB
Vishnu DxB - avatar
+ 1
No but in emascript 6 I wonder where using the keyword Const is not geering towards that?... after second thought, it's something different, const is not a data type as such.
27th Apr 2019, 1:32 PM
Abdoulaye Seck
Abdoulaye Seck - avatar
+ 1
No, js can detect the data type itself
27th Apr 2019, 4:24 PM
Decodeworms Olamilekan
Decodeworms Olamilekan - avatar
+ 1
There is no data type
28th Apr 2019, 8:56 AM
Sonu
0
хуй знает
28th Apr 2019, 7:55 PM
Ilya Golder
Ilya Golder - avatar
0
variable in js can contain any data type. there is no need to declare them
29th Apr 2019, 7:56 AM
anum