FlashKeepers

JavaScript · JavaScript · College and University

JavaScript Basics: Functions and the DOM

JavaScript function syntax, event handling, and basic DOM manipulation methods explained with a short example each.

About this set

42 basic cards for JavaScript JavaScript. Set 1 of 2 in JavaScript Basics. It opens with "What is the syntax for a basic function declaration in JavaScript?" and "How do you write a function expression?". More College and University decks are listed below.

42 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is the syntax for a basic function declaration in JavaScript?
Show answerfunction functionName(parameters) { return value; }
How do you write a function expression?
Show answerconst functionName = function(parameters) { return value; };
What is the arrow function syntax?
Show answerconst functionName = (parameters) => { return value; };
What does a return statement do in a function?
Show answerIt exits the function and sends back a value to the caller.
How do you set a default parameter value in a function?
Show answerfunction greet(name = 'Guest') { return 'Hello ' + name; }
What does the rest parameter (...) allow a function to do?
Show answerAccept a variable number of arguments as an array.
What is function scope in JavaScript?
Show answerVariables declared inside a function are only accessible within that function.
What is a closure?
Show answerA function that has access to variables from its outer function's scope even after that outer function has returned.
What is a callback function?
Show answerA function passed as an argument to another function, to be executed later.
What is an anonymous function?
Show answerA function without a name, often used as a callback or stored in a variable.
What is an IIFE (Immediately Invoked Function Expression)?
Show answer(function() { code here })(); - a function that runs immediately upon definition.
What is function hoisting?
Show answerFunction declarations are moved to the top of their scope before code execution, so they can be called before they are defined.
What does the bind() method do?
Show answerIt creates a new function with a fixed this context and optional pre-filled arguments.
What does the call() method do?
Show answerIt invokes a function with a specified this context and arguments passed individually.
What does the apply() method do?
Show answerIt invokes a function with a specified this context and arguments passed as an array.

27 more cards in the app

Study this set free