Sample Questions Flashcards
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
How to hide an HTLM element using JavaScript?
Set the display style to none
document.getElementById(“demo”).style.display = “none”;
What is the difference between a programming language and a scripting language?
Programming languages are compiled, whereas scripting languages are interpreted.
What is JQuery?
jQuery was designed to focus on client-side scripting. It is an open-source JavaScript library released under the MIT license. It simplifies the syntax of DOM manipulation and eliminates cross-browser incompatibilities
What was server-side JavaScript (SSJS) originally called?
Livewire
What was the original name for JavaScript
Mocha, then Livewire, then JavaScript
What is VB Script?
VBScript is based on the full programming language, Visual Basic. It was developed by Microsoft. Unlike VBScript, JScript and ECMAScript are flavors of JavaScript.
What describes an object-oriented program?
A collection of individual objects that perform different functions.
Which three pop-up boxes are there?
alert, confirm, prompt
Where does JIT stand for?
Just In Time
Some programming languages? (Compiled)
C++
Java
Python
What is an object?
Collection of properties and methods
Define a car object with a drive method
const car = { type: "Fiat", model: "500", color: "white", drive: function () { return "drive" } };
Promp returns…
User closes window –> NULL
User enters string + OK –> STRING
No value entered but OK click –> EMPY STRING
All arithmic operator become assignment operators when….
The arithmic operator is placed in front of the assignment operator
Example:
+=
+ is arithmic
= is assignment
+= will resolve in an assignment operator
What applies ‘’ the internal state of a program’’ ?
variables
When a function produces a value it is said to …..
return it
While / Do loop difference?
Do loop will execute it’s body at least once and only then start testing whether it should continue
Syntax of a For Loop?
for ( let i = 0, i < string.length; i ++ ) { }
1st parameter = initiate the loop
2nd parameter = expression check if loop should run
3rd parameter = counter (mostly ++ indicating to add 1 each iterarion)
Is JavaScript case-sensitive?
Yes
Selft contained set of related values and functions
Object
Example of a type attribute?
type = “application/javascript’’
What should a variable name start with?
Upper or lower case LETTER
$
Underscore
Give an example of assigning a variable
firstName = “Ron”;
What to use to fint out the data type?
typeof
Example:
console.log(typeof variablename);