1/9
Flashcards covering key concepts of arrays, objects, and functions in JavaScript.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
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.
What does the push() method do in arrays?
push() adds an element at the end of the array.
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.
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.
What are the four types of functions in JavaScript?
How do you define an array in JavaScript?
You can define an array by using square brackets, e.g., let subjects = [85, 90, 91].
What method would you use to remove the last element from an array?
You would use the pop() method.
How can functions help in programming?
Functions help modularize and organize code, making it reusable.
What property do strings use to check the number of elements?
Strings use the .length property.
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); } }.