Basics Flashcards

1
Q

JS statement

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

JS expression

A

an expression is a bit of JavaScript code that produces a value which can be captured for later use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is undefined?

A

We can describeundefined as representing the absence of a value. can arise implicitly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is null?

A

nullrepresents emptiness or nothing. null can’t arise implicitly. While null is a primitive, typeOf(null) returns object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a literal?

A

A literal is any notation that lets you represent a fixed value in source code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

give some examples of literals

A

‘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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is are the truthy values in JS?

A

Numbers other than 0 and NaN
Non-empty string values
All objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the falsy values in JS

A

0, -0, 0n
‘’ or “”
NaN, null, undefined
The document.all global object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is short circuit evaluation?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what’s the difference between properties and methods on JS data types?

A

A property says something about the value and a method does something with that value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the two kinds of methods and how are they different?

A

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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the 5 primitive data types in JS?

A

String, Number, Undefined, Null, and Boolean. Every type that is not a primitive is an object type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a template literal?

A

They use backticks (`) and enable string interpolation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Are there any values in JS that can’t equal themselves in comparison operations?

A

NaN is the only value is JS that cant equal itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How should you test if something is a NaN

A

Use Number.isNaN(value)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what happens when you use the + operator with a string and anything else?

A

if either operand is a string and the other is not, JavaScript coerces the non-string operand to a string; thus, the result is always another string.

17
Q

How do you turn a string into a number?

A

You can use Number(’13’) to explicitly coerce a string to number form. You can also use parseFloat() or parseInt() if the string contains non-numerical data.

18
Q

What is an array? What are their defining attributes?

A
  • uses square brackets[ ]surrounding a comma-delimited list of values
    • Can contain any data type in an ordered list
  • Indexed from 0 using a second pair of square brackets
19
Q

What happens if you attempt to access a nonexistent array index?

A

No error will be throw. JS will simply return undefined.

20
Q

What is an Object and what are their key attributes

A
  • Organized by key-value pairs, with each pair consisting of a key, in the form of a string, and a value of any type.
  • object literals have zero or more key-value pairs separated by commas all embedded within curly braces
  • values are accessed by key rather than index
21
Q

How do you access an objects information?

A

using dot or square bracket notation. Note that if you wish to use a variable storing the key you must use bracket notation.

22
Q

how do you tell JS that the next char isn’t syntactic but is part of a string?

A

you can use the \ escape char

23
Q
A