javascript 01 Flashcards
What are the different data
types used in JavaScript?
- string
- number
- BigInt
- Boolean
- null
- undefined
- object
- symbol
Which collections of data
are ordered by a key?
Map and Set objects.
What is the proper syntax for
adding placeholders in template literals?
A dollar sign, followed by curly brackets:
${ expression }
When using the const identifier to create an instance of an object, are the properties changeable?
Yes.
An object declared as const can be modified.
The const fixes the value of the object, but not its contents.
A developer is not able to use a variable outside a function that is defined inside a function.
What could be causing this?
Variables defined inside a function cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of the function.
What are some of the basic DOM data types?
- document
- node
- element
- nodeList
- attribute
- namedNodemap
Events are fired inside the browser window and tend to attach to specific items residing in the browser.
What are some of these items?
A single element, set of elements, the HTML document loaded in the current tab, or the entire browser window.
What are the most important items in your npm package.json file if you plan to publish a package?
The name and version.
Together they form unique identifier for the package.
A developer wants to set a breakpoint in his code while in the editor so they don’t have to switch to the browser. What is the in-line command for setting a breakpoint?
debugger
The debugger command will cause a breakpoint.
What are the two main properties of an error object that’s passed as an argument to catch in a try…catch construct?
name and message
What code block can be executed regardless of wether an exception was thrown or caught in a try…catch block?
The finally block can be used to execute code at the end of a try…catch block. I will run even if no catch block handles the exception.
What are some benefits of using breakpoints?
JavaScript will stop executing at each breakpoint to let you examine the current JavaScript values. After examining the values, you can resume the execution of code. You can even step from breakpoint to breakpoint.
For this code, which of the following code lines will assert the sumArr method adds the numbers in the array passed in?
let res = sumArr([2, 3, 4]);
console.assert(res===9);
Object Properties come in 3 basic types, which are they?
✢ Primitives
✢ Objects
✢ Arrays
Which are the primitive data types in JavaScript?
Number String Boolean NULL Undefined Symbol BigInt