Level 118 Level 120
Level 119

Javascript Data Types


36 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
What data types are there?
numbers, strings, arrays, objects and more:
examples of that
var length = 16; // Number
in a variable
Where do we store the data in js?
js treats them in a different way
Why do we have to know about the type of a data?
var x = 16 + "Volvo";
How does js treat a situation where we want to add a number to a string?
No.
Can a static method be overridden?
In what direction does js evaluate expressions?
JavaScript evaluates expressions from left to right. Different sequences can produce different results:
20Volvo
var x = 16 + 4 + "Volvo";
Volvo164
var x = "Volvo" + 16 + 4;
explanations
In the first example, JavaScript treats 16 and 4 as numbers, until it reaches "Volvo".
What does it mean that JavaScript has dynamic types.
This means that the same variable can be used as different types:
we store them in a variable.
What do we do with datatypes to be able to work with them?
What is a string or text string?
A string (or a text string) is a series of characters like "John Doe".
When can we use quotes inside the quotes?
You can use quotes inside a string, as long as they don't match the quotes surrounding the string: in php you can skip quotes.
example of that
var answer = "It's alright"; // Single quote inside double quotes
What are numbers?
1, 2, 3 etc
How many types of numbers are there?
JavaScript has only one type of numbers.
How can numbers be written?
Numbers can be written with, or without decimals:
integers
What do we call numbers in other words?
How many values do booleans have?
Booleans can only have two values: true or false.
TRUE
What are booleans?
When are the boolean used most often?
Booleans are often used in conditional testing.
What are arrays?
a set of values.
How are js arrays written?
JavaScript arrays are written with square brackets.
how are array items separated?
Array items are separated by commas.
how do we declare (create) an array called cars that contains 3 values?
The following code declares (creates) an array called cars, containing three items (car names):
Array indexes are zero-based,
What kind of index system is used in js?
What does it mean that it is zero-based?
it means the first item is [0], second is [1], and so on.
How are js objects written?
JavaScript objects are written with curly braces.
How are object properties written?
Object properties are written as name:value pairs, separated by commas.
How many properties do the object (person) above have?
The object (person) in the example above has 4 properties: firstName, lastName, age, and eyeColor.
What is undefined value?
In JavaScript, a variable without a value, has the value undefined. The typeof is also undefined.
What is empty value?
An empty value has nothing to do with undefined.
What is The typeof Operator for?
You can use the JavaScript typeof operator to find the type of a JavaScript variable:
example of typeof operator?
typeof "John" // Returns string
Why does typeof [1,2,3,4] return an object?
In JavaScript, an array is a special type of object. Therefore typeof [1,2,3,4] returns object.