Objects, classes, prototypal inheritance Flashcards

1
Q

What do we use to set the value of this in a new object.

A

The methods apply, call, and bind can be used to set what this points to.

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

What is Json

A

Basically a javascript object format in string form

Stands for javascript object notation. It is a text format that makes it easy to share data between devices like client and servers.

It is language independent and is an alternative to XML.

It is extremely easy to parse the text information into a javascript object.

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

How do we convert a object or value into a JSON string?

A

JSON.stringify()

examples
console.log(JSON.stringify({ x: 5, y: 6 }));
// expected output: "{"x":5,"y":6}"
console.log(JSON.stringify([new Number(3), new String('false'), new Boolean(false)]));
// expected output: "[3,"false",false]"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we convert a string in JSON format into objects?`

A

JSON.parse();

var json = '{"result":true, "count":42}';
obj = JSON.parse(json);
console.log(obj.count);
// expected output: 42
How well did you know this?
1
Not at all
2
3
4
5
Perfectly