javascript quirks Flashcards

learning quirks of the JS

1
Q

What is one of the behavioural risks of using document.write?

A

Using document.write after a page reload has the risk of over-writing the page you are on.

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

Explain eval()

A

Eval function is a function property of global object which evaluates java script code then represents it as a string. It can be dangerous function, as it executes the code it’s passed with the privileges of the caller , therefore be used maliciously if someone passes code as its argument. It requires compilation and therefore can be slow.

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

what does ‘….’ do in the code

 const updatedRecords = {
    ...this.state.records
}
A

This is spread operator , which allows an iterable such as an array expression , string or object expression to be expanded in places where zero or more arguments , elements (in arrays) or key-value pairs ( objects) are expected. The const updatedRecords creates a new object by passing expanded key-value pairs from this.state.records.

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

what method would you use to control decimal places in an object?

A

toFixed()

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