Variables and Data Types Flashcards
When you create a veritable you must know the ____ you wish to use with it
Data. Is it a number? Boolean? Decimal?
What sorts of values can you assign a variable?
1) Intergers (Whole #s)
2) Decimals. (.5)
3) Floating point (1.5)
4) one character (a) or whatever
5) Multiple characters (String) “hello”
6) Boolean (true/false)
What is a Strongly Typed Language?
A language where you can not change the type of variable you are using.
If you assign a decimal variable, you CAN NOT use an integer or boolean.
What is a Weakly Typed Language?
A language where you can assign generic variables.
var = name can be whatever you want it to be.
Can you have spaces inside of a string literal?
Sure.
“Hello, world” is an example
Name the kinds of Data Types and give an example.
1) Strings - Written in quotes.
(ex) var carName=”Volco XC60”;
2) Numbers - Integers, decimals or floating(scientific)
(ex) var x1=34.00; or y=123e5; (12300000)
3) Booleans - True/False. Used in testing.
(ex) var x=true;
4) Arrays - Written with square brackets. Essentially variables with multiple possible values.
(ex) var cars=[“Ferrari”, “Acura”, “Cadillac”];
5) Object - They are like arrays but allow for more info. about one variable.
(ex) var darius = {firstName:”Darius”, age:”26”, sex:”male”};
6) typeof - not sure.. you can use these to find out what sort of variable you have.
(ex) typeof={name:’john’, age:”34’};
7) Undefined - Variable with no value.
(ex) var person;
8) Empty - variable with empty string.
(ex) var = “ “;