ES2015 Flashcards

1
Q

var hello = ‘hello’;

function sayHi() {
  var hello = 'hi';
  console.log(hello);
}

sayHi();

A

‘hi”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
var student = { name: 'Ken' };
var student = { name: 'James' };

console.log(student);

A

‘James’

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

var hello = ‘hello’;

function sayHi() {
  var hello = 'hi';
  console.log(hello);
}

sayHi();
console.log(hello)

A

hi

hello

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
const student = { name: 'Ken' };
var student = { name: 'James' };

console.log(student);

A

give error

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

you can declare a let or const variable with the same name in ____________

A

a different scope

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

RETURNS

(function () {
  const student = { name: 'James' };
  function createStudent(name) {
    const student = { name: name };
    return student;
  }

console.log(createStudent(‘Ken’));
console.log(student);
})();

A

Ken

James

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

use ______ when you need to assign a variable , or scope a variable at the block level

A

let

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

use ______ when you don’t want a variable value to change through out the project

A

const

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

let strToSearch = ‘a-really-long-hyphenated-string’;

console. log(/^a-really/.test(strToSearch)); // test string w/ regular expression
console. log(strToSearch.indexOf(‘a-really’) === 0); // indexOf
console. log(strToSearch.startsWith(‘a-really’)); // startsWith

A

all true

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

let strToSearch = ‘a-really-long-hyphenated-string’;

console. log(/hyphenated-string$/.test(strToSearch)); // test string w/ regular expression
console. log(strToSearch.indexOf(‘hyphenated-string’) === strToSearch.length - ‘hyphenated-string’.length); // indexOf
console. log(strToSearch.endsWith(‘hyphenated-string’)); // endsWith

A

all true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
let strToSearch = 'a-really-long-hyphenated-string';
console.log(strToSearch.startsWith('a-really', 5)); // startsWith
A

false

starts at index 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
let strToSearch = 'a-really-long-hyphenated-string';
console.log(strToSearch.endsWith('hyphenated-string', 22)); // endsWith
A

false

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

let and const type variables can be accessed from ______.

A

nested scope

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

let and const are best used for ______.

A

block level scopting

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

MAKE TO ARROW FUN

this.getKeys = function () {
return Object.keys(this);
}

A

this.getKeys = () => {
return Object.keys(this);
}

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

ADD DEFAULT VAULES FOR NAME, TIMEOFDAY

function greet(name, timeOfDay) {
  console.log(`Good ${timeOfDay}, ${name}!`);
}
A
function greet(name = "steve", timeOfDay = "day") {
  console.log(`Good ${timeOfDay}, ${name}!`);
}
17
Q

an arrow function is bound to it’s ______ scope

A

parent

18
Q

Given a function that has two default parameters. You want to keep the default value of the first parameter but override the default value of the second parameter. When calling the function, what value should the first parameter be?

A

undefined

19
Q

block level is any piece of code surrounded in ________

A

{}

braces

20
Q
var i; // i is declared in the containing scope
for(i = 0; i < 10; i++) {
  ... // some code
}
return i; //  accessible or no?
A

accessible here

21
Q

for(var i = 0; i< 10; i++){

}

return i; // i// accessible or no?

A

not accessible here in block scoped language