Javascript Flashcards
Write:
How to include a javascript file?
Is JS a dynamic language?
If so, what does that entail?
It is a dynamic language. As such, the value of the variables can be modified at runtime
What are the three ways to declare variables?
let, var and const
What happens if a variable is created without being declared?
They are global
What happened if a variable is not assigned a value?
Its value is “undefined”
What is a Falsy value?
What are the falsy values?
A value that is not false, but would be false in a Boolean context
undefined, NaN, null, “”, 0
What happens if we try to + a string and a number?
The number is coerced to a string.
What are the five primitive data types in JS?
Number, String, Boolean, null and undefined
What are the comparison rules for < and >
1-If one is a number and the other can be converted: comparison
2-If one is a number and the other one cannot be converted: false
3-If both are strings: string comparison
What are the comparison rules for all the other operators (asterisk, /, %)
If one cannot be converted to a number: NaN
What are the two types of equality operators, and how do they differ?
The loose equality (==, !=) and the strict equality (===, !==). The former does type coercion, the latter does not
For the variable declarator “let”, tell us about its scope, whether it can be redeclared and whether a value must be declared at creation.
Block scope, cannot be redeclared and does not have to be assigned a value at declaration
For the variable declarator “const”, tell us about its scope, whether it can be redeclared and whether a value must be declared at creation.
Block scope, cannot be redeclared and must be assigned a value at declaration
For the variable declarator “var”, tell us about its scope, whether it can be redeclared and whether a value must be declared at creation.
Global scope, can be redeclared and can also be declared before use
How to traverse all properties in an object?
for (x in object){…}