javascript quirks Flashcards
learning quirks of the JS
What is one of the behavioural risks of using document.write?
Using document.write after a page reload has the risk of over-writing the page you are on.
Explain eval()
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.
what does ‘….’ do in the code
const updatedRecords = { ...this.state.records }
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.
what method would you use to control decimal places in an object?
toFixed()