JavaScript Basics: Arrays, Objects, and Functions

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/9

flashcard set

Earn XP

Description and Tags

Flashcards covering key concepts of arrays, objects, and functions in JavaScript.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

10 Terms

1
New cards

What is an array in JavaScript?

An array is a collection of elements stored under one variable, with each element having an index starting from 0.

2
New cards

What does the push() method do in arrays?

push() adds an element at the end of the array.

3
New cards

What is the primary function of objects in JavaScript?

Objects store data as key-value pairs, where each key is a property associated with a value.

4
New cards

What is a function in JavaScript?

A function is a reusable block of code designed to perform a specific task, which can take parameters and return values.

5
New cards

What are the four types of functions in JavaScript?

  1. Simple Function (without return values and parameters), 2. Function with Parameters, 3. Function with Return Values, 4. Higher-Order Functions.
6
New cards

How do you define an array in JavaScript?

You can define an array by using square brackets, e.g., let subjects = [85, 90, 91].

7
New cards

What method would you use to remove the last element from an array?

You would use the pop() method.

8
New cards

How can functions help in programming?

Functions help modularize and organize code, making it reusable.

9
New cards

What property do strings use to check the number of elements?

Strings use the .length property.

10
New cards

In the context of JavaScript, what is an example of an object?

let student = { name: 'John Doe', age: 20, subjects: ['Math', 'Science'], greet: function() { console.log('Hello, ' + this.name); } }.