JavaScript Fundamentals Flashcards

(72 cards)

1
Q

What was JavaScript initially called?

A

LiveScript

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

What is the specification for JavaScript?

A

ECMAScript

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

True or False: JavaScript and Java are the same.

A

False

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

List three benefits of using JavaScript.

A
  • Full integration with HTML/CSS
  • Simple things are done simply
  • Support by all major browsers and enabled by default
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the primary task of a JavaScript engine?

A

To convert (compile) the JavaScript to machine-executable binaries.

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

What are two examples of JavaScript engines?

A
  • V8 (Chrome, Opera, Edge)
  • SpiderMonkey (Firefox)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the basic structure of JavaScript code?

A

JavaScript commands are written in statements separated by semicolons.

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

What are the keywords used to declare a variable in JavaScript?

A
  • const
  • var
  • let
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What characters are allowed in variable names?

A
  • Letters
  • Digits
  • Symbols $ and _
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the special value that represents nothing in JavaScript?

A

null

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

What does the Boolean type represent?

A

Two values: true and false.

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

What is the maximum safe integer value in JavaScript?

A

2**53 - 1 (9,007,199,254,740,991) - just over 9 quadrillion

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

Fill in the blank: In JavaScript, a _______ is a special value that indicates a variable has been declared but not assigned a value.

A

undefined

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

What is the syntax to create a string with embedded expressions?

A

Backticks (``)

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

True or False: All data types in JavaScript are considered primitive except for objects.

A

True

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

What operator is used to check the type of a variable?

A

typeof

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

What is the result of typeof null?

A

object

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

What is the purpose of the String class function in type conversion?

A

To explicitly convert other types to strings.

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

What happens during implicit numeric conversion in JavaScript?

A

Strings are automatically converted to numbers in mathematical operations.

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

List three values that convert to false in Boolean conversion.

A
  • ””
  • 0
  • null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does a variable declared but not assigned a value return when logged?

A

undefined

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

How can you create a BigInt in JavaScript?

A

By appending ‘n’ to an integer.

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

What is a key characteristic of JavaScript as a programming language?

A

JavaScript is a dynamically typed language.

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

What is the output of console.log(NaN ? ‘NaN is true’ : ‘NaN is false’)?

A

NaN is false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the output of console.log(0 ? 'zero is true' : 'zero is false')?
zero is false
26
What is the output of console.log('hello' ? 'hello is true' : 'hello is false')?
hello is true
27
What does the negation operator (!) do?
Converts a value to boolean and then negates it
28
What is the output of console.log(!undefined)?
true
29
What is the output of console.log(!!"" )?
false
30
How does JavaScript compare strings?
Using dictionary or lexicographical order
31
What is the first step in comparing two strings?
Compare the first character of both strings
32
If both strings have the same first character, what should be done next?
Compare the second characters the same way
33
What is the output of console.log('apple' < 'banana')?
true
34
What happens when comparing different types using >, <, == and !=?
JavaScript converts the values to numbers
35
What is the output of console.log('2' > 1)?
true
36
What does the 'return' keyword do in a function?
Sends a value back to where the function was called
37
What is the syntax for a function declaration?
function functionName(parameters) { // function body }
38
What is the purpose of the DRY principle in programming?
Avoiding repetition by defining code once and calling it multiple times
39
What is the difference between function declaration and function expression?
Function declaration can be hoisted; function expression cannot be accessed before definition
40
What is an arrow function?
A concise version of function expression using => syntax
41
How do arrow functions differ from regular functions in terms of 'arguments'?
Arrow functions cannot access the 'arguments' variable
42
What is an object in JavaScript?
A complex variable that stores keyed collections of various data
43
How can an object be created in JavaScript?
Using curly brackets {} or the Object constructor
44
What is a property in an object?
A key:value pair where key is a string and value can be anything
45
What happens when accessing a non-existing property of an object?
It returns undefined
46
How can you iterate over all keys of an object?
Using a for ... in loop
47
What is the output of console.log(object) if object = { 2: 'value of numeric property', '2': 'value of string property' }?
{ '2': 'value of string property' }
48
What is the difference between shallow copy and deep clone?
Shallow copy replicates the structure but not nested object properties; deep clone copies all levels
49
What is a method in the context of an object?
A function that is a property of an object
50
How can an object method access its own properties?
Using the 'this' keyword
51
What keyword is used to access the information stored in an object within its methods?
this
52
In the context of an object method, what does the value of 'this' refer to?
The object before the dot, the one used to call the method.
53
What is the output of user.printGreeting() when user is defined as { name: 'Bilbo Baggins', printGreeting() { console.log(`Hello, I'm ${this.name}`) } }?
Hello, I'm Bilbo Baggins
54
True or False: The value of 'this' in JavaScript is evaluated at compile-time.
False
55
What allows methods to be chained together in JavaScript objects?
Returning 'this' from a method.
56
What are the naming conventions for constructor functions in JavaScript?
Named with a capital letter first.
57
What must be used to execute a constructor function?
The new operator.
58
What is the first step when a function is executed with the 'new' keyword?
A new empty object is created and assigned to 'this'.
59
What is one difference between constructor functions and ES6 classes?
Classes have an explicit constructor function.
60
Fill in the blank: In ES6, the new syntax keyword _______ is introduced for creating object blueprints.
class
61
What does the hasShortName method return for a user with first name 'Tim'?
true
62
List three advantages of programming in JavaScript.
* Event-driven * Asynchronous * High-level
63
What are the three keywords used to create a variable in JavaScript?
* var * let * const
64
What are five common variable data types in JavaScript?
* Number * String * Boolean * Object * Undefined
65
What are the three types of quotes used to create a string in JavaScript?
* Single quotes * Double quotes * Backticks
66
What is the difference between null and undefined?
Null is an intentional absence of value; undefined means a variable has been declared but not assigned.
67
How can we convert a variable to a string in JavaScript?
Using String() or .toString() method.
68
How can we convert a variable to a number in JavaScript?
Using Number() or parseInt()/parseFloat() methods.
69
What is a boolean?
A data type that can be either true or false.
70
What are the three ways to create a function in JavaScript?
* Function declaration * Function expression * Arrow function
71
What is an object in JavaScript?
A collection of properties, each defined as a key-value pair.
72
How can we create an object in JavaScript?
Using object literal syntax or constructor functions.