Module 3 Flashcards
(47 cards)
What is Array.prototype.filter useful for?
It helps create a new array with elements of the array matching specified parameters, which lets you search for specific elements.
What is Array.prototype.map useful for?
It is useful for making changes to all elements of an existing array and assigning it to a new array, without actually modifying the original array.
What is Array.prototype.reduce useful for?
To combine bunch of data using a defined function into one result
What is “syntactic sugar”?
Syntax in a programming language that is designed to be easier to read by humans
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
Declare class ClassName { constructor( ) { } method( ) { } }
What is “refactoring”?
Restructuring code without changing its behavior
Does a class need constructor within?
No
What is Webpack?
Module bundler, takes files and groups into one file
What is an NPM script?
A way to write common commands in a short way rather than typing out the whole thing. Typically stored in package.json, takes a saved command and executes for you.
How are ES Modules different from CommonJS modules?
Syntax differences, ESM can use the import and export keywords, are more compact since it is built in.
What kind of modules can Webpack support?
ES modules, commonJS modules, nearly every JS module.
What is React?
A js library for building user interfaces, it is a javaScript framework for building webpages. Makes setting up a webpage easier than direct dom manipulation.
What is a React element?
A dom element created by react
How do you mount a React element to the DOM?
You use React.createElement( );
What is Babel?
A toolchain that converts ES6 script into backwards compatible JS. Can also convert JSX
What is a Plug-in?
A software addon component that adds a specific feature to an existing computer program
What is a Webpack loader?
A transformation that is applied to source code to transform files from different languages into JS or load inline images as data URLs
How can you make Babel and Webpack work together?
Using Babel Loader, it works such that webpack reads the files, passes it through babel to convert, then gets a converted language back to package.
What is JSX?
A html-like markup language that can be used with JavaScript and React. But note it is neither HTML nor JavaScript.
Why must the React object be imported when authoring JSX in a module?
JSX cannot be read by browsers by default, need to be converted. Babel converts JSX to React.createElement(‘tag’, props, ‘textContent’)
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
Use babel loader to connect babel to webpack then the plugin @babel/plugin-transform-react-jsx
What is a React component?
They split a ui into independent reusable pieces.
How do you define a function component in React?
Any javaScript function that takes one argument props and returns a React element