Module 3: JavaScript

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/92

encourage image

There's no tags or description

Looks like no tags are added yet.

93 Terms

1
New cards

What is JavaScript?

A programming language used to store, compute, reuse, and search information in programs.

2
New cards

What is a data type?

Describes what kind of value is used and which operations JavaScript can perform on it.

3
New cards

What are the seven primitive types in JavaScript?

String, Number, BigInt, Boolean, Undefined, Null, and Symbol.

4
New cards

What is a reference type?

A type commonly represented by Object, including objects, arrays, and functions.

5
New cards

What does the typeof operator do?

Inspects a value's type.

6
New cards

What is a String?

A data type that represents text, such as "Hello", 'JavaScript', or Welcome, ${name}!.

7
New cards

What is string concatenation?

Combining strings, commonly using +. Example: let fullName = firstName + lastName;.

8
New cards

What are common string operations?

Checking length, searching within text, and extracting part of a string.

9
New cards

What does toUpperCase() do?

Converts text to uppercase.

10
New cards

What does toLowerCase() do?

Converts text to lowercase.

11
New cards

What does includes() do?

Checks whether text contains a specified piece of text.

12
New cards

What does slice() do?

Extracts part of a string.

13
New cards

What is the Number data type?

Represents numeric values used in calculations. Example: let total = 150 * 3;.

14
New cards

What is a Boolean?

A value representing a true/false condition: true or false.

15
New cards

What is a comparison operator?

Compares values and produces a Boolean. Example: 10 > 5 returns true.

16
New cards

What are JavaScript's logical operators?

&& means AND, || means OR, and ! means NOT.

17
New cards

What does undefined represent?

A value that has not been assigned.

18
New cards

What does null represent?

An intentional absence of a value.

19
New cards

What is an Object?

A structure that groups related properties and values.

20
New cards

What is an Array?

An ordered collection of values. Example: let scores = [85, 90, 92];.

21
New cards

What is dot notation?

Accesses a property by name, such as student.name.

22
New cards

What is bracket notation?

Accesses a property or array item using brackets, such as scores[0].

23
New cards

What is an expression?

A piece of code that produces a value.

24
New cards

What are JavaScript's arithmetic operators?

+ addition, - subtraction, * multiplication, / division, % remainder, and ** exponentiation.

25
New cards

What are assignment operators?

Operators that assign or update values, such as =, +=, -=, *=, and /=.

26
New cards

What are common comparison operators?

===, !==, >, <, >=, and <=.

27
New cards

What is an average expression?

An expression that calculates the mean. Example: let average = (score1 + score2) / 2;.

28
New cards

What is operator precedence?

The order in which JavaScript evaluates parts of an expression.

29
New cards

How do parentheses affect operator precedence?

They are evaluated first and clarify the intended order of operations.

30
New cards

Which operators generally take precedence over addition and subtraction?

Multiplication, division, and remainder.

31
New cards

What is the result of 10 + 5 * 2?

20, because multiplication happens before addition.

32
New cards

What is the result of (10 + 5) * 2?

30, because the parentheses are evaluated first.

33
New cards

What does strict equality (===) check?

Whether values are equal without converting them to another type.

34
New cards

What does strict inequality (!==) check?

Whether values are not strictly equal.

35
New cards

What is conditional logic?

Using conditions to control program decisions.

36
New cards

What is an if statement?

Runs code when a condition is true. Example: if (age >= 18) { ... }.

37
New cards

What does else do?

Provides an alternative branch when the if condition is not true.

38
New cards

How can multiple conditions be combined?

Use && for AND and || for OR.

39
New cards

What is a function?

A reusable block of code that performs a task.

40
New cards

What is a function declaration?

Defines a function using the function keyword. Example: function greet(name) { return name; }.

41
New cards

What is a parameter?

A named input received by a function.

42
New cards

What does return do in a function?

Sends a result back from a function.

43
New cards

What is a function call?

Runs a function. Example: greet("Ana").

44
New cards

What is a function expression?

Stores a function in a variable. Example: const add = function(a, b) { return a + b; };.

45
New cards

What is an arrow function?

A concise function syntax. Example: const add = (a, b) => a + b;.

46
New cards

What are the benefits of functions?

They support reuse, organization, testing, and reduced repetition.

47
New cards

How should you choose a function style?

Choose a style that keeps code clear and consistent.

48
New cards

What is a method?

A function associated with an object or value.

49
New cards

What is the difference between a function and a method?

A function is a reusable action; a method is accessed through an object or value.

50
New cards

What are examples of string methods?

text.toUpperCase() and text.includes("JS").

51
New cards

What does the array push() method do?

Adds an item to an array. Example: scores.push(95).

52
New cards

What does the array map() method do?

Transforms each item in an array into a corresponding result.

53
New cards

What does the array filter() method do?

Selects array items that meet a specified condition.

54
New cards

What does the array reduce() method do?

Combines array items into a single accumulated result.

55
New cards

How can reduce() calculate a sum?

Example: scores.reduce((sum, score) => sum + score, 0).

56
New cards

How can JavaScript calculate an average and status?

Calculate the sum with reduce(), divide by the array length, then use a condition such as average >= 75 ? "Passed" : "Needs Improvement".

57
New cards

What are object methods?

Methods associated with objects that can operate on the object's data.

58
New cards

What is pattern matching?

Checking whether text follows a desired structure for searching, filtering, extracting, or validating.

59
New cards

What is a regular expression (RegExp)?

A description of a text pattern used for flexible text matching in JavaScript.

60
New cards

What are common uses of pattern matching?

Finding digits, detecting keywords, checking simple email formats, validating forms, and cleaning data.

61
New cards

How is a regular expression literal written?

/pattern/flags.

62
New cards

What does [A-Z] match?

Any uppercase letter from A through Z.

63
New cards

What does [0-9] match?

Any digit from 0 through 9.

64
New cards

What does \d mean in a regular expression?

Matches a digit.

65
New cards

What does \w mean in a regular expression?

Matches a word character, generally a letter, digit, or underscore.

66
New cards

What does \s mean in a regular expression?

Matches whitespace, such as spaces or tabs.

67
New cards

What does the + quantifier mean?

Matches one or more occurrences.

68
New cards

What does the * quantifier mean?

Matches zero or more occurrences.

69
New cards

What does the ? quantifier mean?

Makes the preceding element optional.

70
New cards

What does {n} mean in a regular expression?

Matches exactly n repetitions of the preceding element.

71
New cards

What does the ^ anchor mean?

Marks the beginning of a string or line, depending on flags.

72
New cards

What does the $ anchor mean?

Marks the end of a string or line, depending on flags.

73
New cards

What does /^\d{4}$/ match?

Exactly four digits in the entire string.

74
New cards

What does the RegExp test() method do?

Tests whether text matches a regular expression and returns true or false.

75
New cards

What does /^\d+$/.test("123") return?

true, because the string contains one or more digits only.

76
New cards

What does the match() method do?

Returns matched text. Example: "Room 123".match(/\d+/).

77
New cards

What does the replace() method do?

Replaces matching text. Example: text.replace(/\s+/g, " ").

78
New cards

What does the search() method do?

Returns the position of a match, or -1 if no match is found.

79
New cards

What does the g regular expression flag mean?

Global matching, finding all matches instead of stopping after the first.

80
New cards

What does the i regular expression flag mean?

Case-insensitive matching.

81
New cards

What does the m regular expression flag mean?

Multiline mode, changing how ^ and $ match line boundaries.

82
New cards

How can a student ID like 2026-00123 be validated?

Use /^\d{4}-\d{5}$/ and test the ID with pattern.test(studentID).

83
New cards

What does the student ID pattern /^\d{4}-\d{5}$/ require?

Four digits, a hyphen, then five digits, with no extra characters.

84
New cards

What is a validation rule?

A rule used to check whether input meets specified requirements.

85
New cards

Why should validation rules match actual requirements?

To avoid accepting invalid input or rejecting valid input.

86
New cards

How do JavaScript concepts work together in a student registration form?

Data types store student information; expressions calculate values; functions organize processing; methods manipulate data; regex validates structured inputs.

87
New cards

What is the difference between = and ===?

= assigns a value, while === checks strict equality.

88
New cards

What should you remember about array indexing?

Array indexes start at 0, not 1.

89
New cards

What can happen when a function is called without required arguments?

It may not work as intended because expected inputs are missing.

90
New cards

What happens when a regular expression is too broad?

It may accept invalid input.

91
New cards

What happens when a regular expression is too strict?

It may reject valid input.

92
New cards

What are useful JavaScript debugging tips?

Test small pieces, inspect values with console.log(), and use clear variable names.

93
New cards

What makes code readable?

Code that is predictable, clearly named, organized, and easy to test.