Basics Flashcards
JS statement
A statement is an instruction for the computer to do something ie let x=10. function calls and assignments are included in MDN but not the official specs
JS expression
an expression is a bit of JavaScript code that produces a value which can be captured for later use
What is undefined?
We can describeundefined as representing the absence of a value. can arise implicitly.
What is null?
nullrepresents emptiness or nothing. null can’t arise implicitly. While null is a primitive, typeOf(null) returns object.
What is a literal?
A literal is any notation that lets you represent a fixed value in source code
give some examples of literals
‘Hello, world!’ // string literal
3.141592 // numeric literal
true // boolean literal
{ a: 1, b: 2 } // object literal
[ 1, 2, 3 ] // array literal
undefined // undefined literal
What is are the truthy values in JS?
Numbers other than 0 and NaN
Non-empty string values
All objects
What are the falsy values in JS
0, -0, 0n
‘’ or “”
NaN, null, undefined
The document.all global object
What is short circuit evaluation?
this means expressions are evaluated from left to right until it is confirmed that the result of the remaining conditions is not going to affect the already evaluated result
what’s the difference between properties and methods on JS data types?
A property says something about the value and a method does something with that value
What are the two kinds of methods and how are they different?
Instance methods and static methods.
- you apply instance methods to a value of the type that the constructor represents (ie ‘hello’.toUpperCase())
You apply static methods to the types constructor itself (ie String.fromCharCode(97)
)
Instance methods are designated with a .prototype.method()
What are the 5 primitive data types in JS?
String, Number, Undefined, Null, and Boolean. Every type that is not a primitive is an object type.
What is a template literal?
They use backticks (`) and enable string interpolation
Are there any values in JS that can’t equal themselves in comparison operations?
NaN is the only value is JS that cant equal itself
How should you test if something is a NaN
Use Number.isNaN(value)