JS Basics (HR) Flashcards

1
Q

what is the type of “hi”

A

string literal

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

what type is - true - and what cn it represent?

A

boolean. represents opposing ideas, such as on vs off, positive vs negative, present vs absent, or truth vs falsehood

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

what is the type - underfined - and what does it represent?

A

undefined value represents an unknown or undetermined state. Will receive this value, when someone or some system is trying to indicate to you that the info you’re inquired about could not be found.

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

what is the type of 3

A

number literal

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

what do you need in order to make calculations

A

Operators. Operators are things like plus, known as the addition operator, and they imply that some work should be done on the values around them. Research operator precedence if i want to learn more about order of operations

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

What are expressions?

A

A set of literals, variables and operators intended to tell your computer how to take one small step forward in a larger computation. When processes at run time, every expression will have a result value. It will “evaluate to”

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

where to go for understanding how my JS interpreter will process my code, and it what order.

A

http://jsparse.meteor.com

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

what is this type of statement? log((3+1)* 2);

A

expression statement. the semicolon has effect of discarding the result value of the full, compound expression occupying the entire line, allowing the interpret to proceed with clean slate

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

how would you describe this? var result = (3+1) * 2;

A

Variable declaration statement.

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

describe a variable

A

storing a previously-computed value by naming it with a variable. A variable can be thought of as a “label” or “alias” that points to some value stored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
What will the var other log to the console in this scenario?
var result = (3+1)*2;
log(result);
var other = result;
result = 5;
console.log(other);
A
  1. This is because other will store the original value, since our new (overwriting) assignment operation told teh interpreter to make result point to something different, but it did not tell the interpreter to make other point to something different.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is it called to define an object like this: var myObj = {};

A

Object literal

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

In an object, what is the combination of one key and one value called?

A

property

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

What does a failed property lookup evaluate to?

A

undefined

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

when accessing accessing or assigning properties with bracket access

A

the value, if not already a string, gets stringified before lookup

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

True/False -> you can do a for/in loop on arrays

A

True

17
Q

True/False -> arrays can have non-integer keys

A

True, but they do not count towards their “length”

18
Q

What are “enumerable” properties of an array

A

they are certain built-in properties that Javascript knows you don’t want to iterate over in a for (with semicolons) loop for example

19
Q

are functions, objects?

A

yes, they can store properties just like any other object. you can’t run function.length on them though, as that is reserved for Arrays. you could iterate through them only with for/in loops though

20
Q

what is it called to activate whatever behavior that function is capable of?

A

to Invoke.

21
Q

how to you make a function run?

A

you put brackets () at the end of it. this will make what is inside the {}, known as the body, run.

22
Q

what is the work done to the environment around it (such as logging a message to the console) called?

A

a Side Effect

23
Q

what always returns if there is no “return” statement in a function?

A

undefined

24
Q

will the lines inside the {} run automatically?

A

No, only when the function is invoked with (), will it run. It will never run, not even once, until it is invoked with a ()

25
Q

what is “hi” considered to be when calling the function fun(“hi”);

A

the Argument

26
Q

talk about the arguments object in a function

A

it is a special keyword called ‘arguments.’ instead of being assigned to a value with the assignment operator, the arguments keyword just automatically holds a brand new array every time you invoke the contain function. the elements coin the array will be the arguments that got passed during the current invocation

27
Q

how to create an parameter via the arguments object?

A

NOT LIKE THIS:
var fun = function(input){
console.log(input.toUpperCase());
}

BUT LIKE THIS:
var fun = function(){
	var input = arguments[0];
	console.log(input.toUpperCase());
}
28
Q
what happens when you refer to a parameter by its name, even though no corresponding argument was passed in during the invocation?
var fun = function(input){
	console.log(input.toUpperCase());
}
fun();
//logs what??
A

undefined

29
Q

what will happen if you try to refer to arguments from within a nested function?

A

that reference to arguments will refer to an array of values that were passed in to the inner function

30
Q

can you use the same variable for parameters in nested functions?

A

Yes, you can use the same variable names

31
Q

setTimeout, is a native function that takes two parameters - (myFunk, time to run myFunk). how would you run myFunk, which takes a parameter? (Note: setTimeout does not allow for adding a parameter to myFunk

A

Wrap myFunk in an anonymous function, that passes in a parameter into myFunk like this:

setTimeout(function(){
myFunk(‘hi’);
}, 1000);

32
Q

Are you allowed to assign properties to an Object that is set to “null” or “undefined”?

A

Nope. it will throw an error

33
Q

what are immutable values?

A

It means you can’t modify them (by adding properties to them). Immutable objects include: booleans, Strings, and Numbers

34
Q

what is a method?

A

an object’s property that is pointing to a function