Sample Questions Flashcards
(122 cards)
What are the standard objects available?
window & document
What is a primitive value?
A primitive value is a value that has no properties or methods
Which types (5) of primitive values are there?
String Number Boolean Null Undefined
Are primitive values mutable?
No, Primitive values are immutable (they are hardcoded and therefore cannot be changed).
Can JavaScript variables contain many values?
Yes. Objects are variables too. But objects can contain many values.
Object values are written as name : value pairs (name and value separated by a colon).
let person = { firstName: "Ron" , lastName: "de Vries", }
What are named values, in JavaScript objects, called?
Properties
How do you call an action that can be performed on objects?
Methods
What is an object literal?
You define and create an object in one statement
const person = { firstName: "Ron", lastName: "de Vries", age: 35 }
How to add a new object?
Use the keyword new
const person2 = new Object();
person2. firstName = “Ron”,
person2. lastName = “de Vries”;
How are objects addressed?
By reference, not by value
const x = person; // Will not create a copy of person. X is not a copy of person, it is person
What are some flavors of JavaScript?
TypeScript
CoffeeScript
JScript (Microsoft)
What is isomorphic JavaScript?
Code that can be run either on the client or server side
Which primitive data type has been added in ES6?
symbol
Why is it dangerous to use document.write?
If it’s used after the page has rendered (loaded) it will delete all content
What is returned if user cancels the prompt() ?
Null
What does the confirm() method return?
A boolean value; ok = true, cancel = false
What is block scope?
Variables declared inside a code block can’t be accessed outside of that block
What are the logical operators?
&& (AND), || (OR), ! (NOT)
What is the result if you add a number and a string?
String
What is the difference between a function declaration and an function expression?
Function declarations load before any code is executed. Expressions load only when the interpreter reaches that line of code
How does the Ternary Operator look like? Also called Conditional operator
x = myBoolean ? “Ok” : “Not ok”;
It takes three expression. If statement is true (x = myBoolean) “Ok” will be executed. If fasel, “Not ok” will be printed
What does the NOT (!) operator return
True for false statements
False for true statements
When comparing two string, what will be greater…. 2 or 12?
2 will be greater, because (alphabetically), 1 is less then 2. JS always looks at the first number
How to secure a proper result when comparing variables?
Convert them into the proper type before comparison
Paragraph