Theory

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Why use a useEffect hook in React.

Any manipulation with the DOM or retrieving and writing data outside components make this side effects. To avoid side effect in pure components use useEffect hook that runs after component is rendered. Put the code that produces the side effect into the callback of the useEffect function.

When to use the PHP htmlspecialchars( ) function?

Any time you display user input within HTML code, use htmlspecialchars( ). It prevents XSS attacks.

What is ArrayBuffer in JavaScript?

ArrayBuffer is a basic binary object, a reference to a fixed-length contiguous memory area (in bytes).

What datatype MongoDB uses?

BSON. It is a typed version of JSON.

In Dockerfile what is the difference between CMD and ENTRYPOINT?

CMD describes commands (or arguments) that could be rewritten during container creation from the image. ENTRYPOINT describes commands that always run during container creation. They cannot be rewritten. in Dockerfile: ENTRYPOINT ["/usr/bin/my-app"] CMD ["help"] in Bash: $ docker run my-image:latest # Executes /usr/bin/my-app help $ docker run my-image:latest version # Executes /usr/bin/my-app version When an image is created without an ENTRYPOINT, Docker defaults to using /bin/sh -c.

What are the benefits of working with the Cloud?

Cheaper to use Modern resources for modern needs Ease of testing, integration and production High availability High scalability

What is a structure (components) of a NoSQL database?

Collections (tables), documents (rows)

What is DataView in JavaScript?

DataView is a special super-flexible "untyped" view over ArrayBuffer. It allows to access the data on any offset in any format. DataView is great when we store mixed-format data in the same buffer. For example, when we store a sequence of pairs (16-bit integer, 32-bit float), DataView allows to access them easily.

What are the steps to prevent event loop blocking in Node.js?

Do not use sync functions in fs, crypto and zlib modules in callback functions. Do not preform complex calculations (loops inside loops). Be careful with JSON in large objects. Do not use too complex regular expressions.

What is EC2?

Elastic Compute Cloud. An Amazon Web Service that allows to create and use a virtual machine (usually as a server) in the cloud.

What libraries (packages) to use in order to validate forms in React?

For form handling use react-hook-form For form validation use zod with hookform resolvers

How React update component state?

For the performance reasons React update states asynchronously. To minimize unnecessary re-renders it batches the updates, applies them all at once, and then re-renders the component. React keeps the state in memory while the component is on the screen.

What are the key features of a NoSQL database (MongoDB)?

Free and open source. Scalability: easy to distribute data across many machines Flexibility: no document schema required Performance.

What is a pure function?

Given the same input it always returns the same output. In other words it has no side effects.

In Node.js Express app which package to use to set all security headers?

Helmet

In bash what is the difference between redirect ( > ) and pipe ( | )?

If it's command to command, use a pipe. If you are outputting to or from a file use the redirect.

When to use PATCH method and when PUT method (HTTP)?

If you want to update entire object, use PUT If you want to update a property (or some of the properties) use PATCH

What is the difference in use of single and double quotes in PHP?

In PHP strings in single quotes and double quotes are used differently: Single quotes represent simple strings, in which almost all characters are used literally. Double quotes encapsulate complex strings that allow for special escape sequences and for variable substitution, which makes it possible to embed the value of a variable directly in a string, without the need for any special operator.

Why in MongoDB (any document database) it is important to know the exact type to one-to-many relationship?

In data modeling it is important to discern the types (one-to-few, one-to-many, one-to-ton) in order to normalize (reference) or denormalize (embed) data.

Which library to use for displaying icons in React?

Install and use react-icon library.

What grep command is doing?

It helps to find a text in file.

In Express, what is a middleware stack?

It is like a pipeline of middleware functions between the request and response. The functions are are chained with the next( ) method.

What is "match" expression in PHP8?

It is like a switch but with a different syntax:

What is generic in TypeScript?

It is like a type placeholder that could be replaced by any suitable type during the code execution.

What is useRef hook doing in React?

It is used to create a DOM element reference.

In MongoDB what $ means?

It means a query operator. For example less-than-equal operator: db.users.find( { age: { $lte: 25 } } )

In Node.js what event loop does?

It runs all callback functions (non top-level code)

In bash, what really command "touch" is doing?

It updates the timestamp of the file. If the file with this name exists it updates the timestamp, if not, it creates a new empty file.

What axes the CSS flexbox has?

Main and cross axes

How to make the useEffect hook to run every time after the component is rendered?

Make sure that useEffect has only the callback function and no other parameters: useEffect( callback )

How to make the useEffect hook to run only once after the component is rendered?

Make sure that useEffect has the callback function and a dependency-list parameter that is an empty array: useEffect( callback, [ ] )

How to make a clean up in the useEffect hook in React?

Make the callback function of the useEffect to return that cleanup function.

Is SQL syntax case sensitive?

No, but MySQL makes difference in table names.

In PHP what is the difference between array_key_exists( ) and key_exists( )?

None. key_exists( ) is an alias of array_key_exists( )

What is OAuth?

OAuth stands for open authorization. The OpenID Connect layer provides Authentication standards on top of the OAuth. Now OAuth 2 is the way to run single sign-on.

What is the Observer design pattern and when to use it?

Observer design pattern is of the behavioral type when individual objects can subscribe to or unsubscribe from a stream of events coming from the publisher.

How many threads in Node.js

One main thread with an event loop and at least 4 more threads in a thread pool for expensive computation the the main thread can use if need be.

Is PHP a functional language?

PHP is considered by many to be a functional language, as functions are first-class elements in the language and can be bound to variable names, passed as arguments, or even returned from other functions.

What is the difference between a promise and web worker?

Promise assigns a reference to a result not yet available, and organizes code that runs once the result becomes available. Web Worker performs actual work asynchronously using operating system threads.

In JavaScript what is the difference between Promise.all( ) and Promise.allSettled( )?

Promise.all( ) will reject immediately upon any of the input promises rejecting. Promise.allSettled( ) will wait for all input promises to complete, regardless of whether or not one rejects.

What is the difference between CSS pseudo-class and pseudo-element?

Pseudo-classes (a:hover) enable you to target an element when it's in a particular state, as if you had added a class for that state to the DOM. Pseudo-elements (p::after) act as if you had added a whole new element to the DOM, and enable you to style that.

In Dockerfile what is the difference between RUN and CMD?

RUN - command triggers while we build the docker image. CMD - command triggers while we launch the created docker image.

What types of streams exist in Node.js?

Readable streams (to consume data from) http requests Writable streams (to write data to) http responses Duplex streams (both readable and writable) web sockets Transform streams (duplex streams that transform data as it is written or read) gzipping

In JavaScript how bubbling differs from capturing?

Relating to events, bubbling goes from the inner element outside, capturing goes from the oldest parent to the child.

What is SVG and when to use it?

SVG stands for Scalable Vector Graphics. It defines vector-based graphics in XML format. Every element and every attribute in SVG files can be animated. SVG can be created and edited with any text editor. Can be searched, indexed, scripted, and compressed. Can be printed with high quality at any resolution.

What is SAML?

Security Assertion Markup Language is an XML-based open standard used for exchanging authentication and authorization data between different parties, such as single sign-on, and identity federation.

What is serialization?

Serializing of objects is a conversion of complex data type (found in objects or arrays) into a primitive data type in order to store the data in session or a database.

What is shell?

Shell is a computer interface to an operating system.

What is the difference between synchronous and asynchronous function in JavaScript?

Synchronous function contains instructions that awaits previous ones to finish their execution. Asynchronous eliminates that wait.

How Tailwind CSS helps with styling React components?

Tailwind adds a utility classes that can be used as a normal class names. Much as with the CSS Bootstrap, each utility class represents a CSS property that may be applied to the element: className="p-1" means apply padding of 1em.

What is terminal?

Terminal is a program that runs shell.

What is the difference between OR operator and ?? in JavaScript?

The OR operator || uses the right value if left is falsy (null, undefined, NaN, ' ', false, 0. The nullish coalescing operator ?? uses the right value if left is null or undefined.

What is the Aggregation Pipeline in MongoDB?

The aggregation pipeline refers to a specific flow of operations that processes, transforms, and returns results. In a pipeline, successive operations are informed by the previous result. Let's take a typical pipeline: Input > $match > $group > $sort > output.

What eval( ) is doing in JavaScript?

The eval( ) function evaluates JavaScript code represented as a string and returns its completion value. The source is parsed as a script. Warning: Executing JavaScript from a string is an enormous security risk.

What are props is React components?

They are immutable variables that act like input to the component.

What is .d.ts files for?

They describe the shape of an existing module and they only contain type information used for type checking.

How to use CSS pseudo-element ::before and ::after

This element is added to the page after the rest of CSS have been applied to the page and either inserts content before or after the element. Always use these pseudo-elements with the content property ::auto { content: url("image.png") }

What is currying in PHP?

This is the practice of changing a function with multiple input parameters into a series of functions, that each take a single parameter, with most of those parameters being functions themselves:

In JavaScript what is Uint8Aray?

Uint8Array is a "viewer" object for ArrayBuffer. It also called "TypedArray". It treats each byte in ArrayBuffer as a separate number, with possible values from 0 to 255 (a byte is 8-bit, so it can hold only that much). Such value is called a "8-bit unsigned integer".

In Express, what to use as a middleware package for logging?

Use "morgan" package.

How to pass an HTML or text that is located inside the tags down to the component in React?

Use 'children' props. They are of the type 'string' or 'ReactNode'

In JavaScript how to get access to code from one script file to another?

Use CommonJS module with require( ) and module.exports (Used in Node.js) or ES (ECMA Script) module with import/export formats.

In Express, how to serve a static html file?

Use a build-in static middleware function: app.use( express.static( './path-to-static-folder' ) )

How to remove or add any element in an array in PHP?

Use array_splice( )

How to access filesystem from browser with JavaScript?

Use either a <input type="file"> or via drag-and-drop. Use FileReader to access the contents of the file(s).

How to center text in a container with CSS?

Use flexbox: display: flex justify-content: center align-items: center

With Express (Node.js) how to set an optional parameter in a request url string?

Use question mark: app.get( '/api/:a/:x?'

Using CSS flexbox, how to make the last element in the container obtain the entire empty space?

Use the container's item property flex-grow: flex-grow: 1

Using CSS flexbox, how to make the element never shrink more than it's height or width?

Use the container's item property flex-shrink: flex-shrink: 0

How can we get a value of a form input in React?

Using useRef( ) hook or using useState( ) hook

What is variadics operator in PHP8 and what it is used for?

Variadics operator is also called spread operator and represents three dots before the variable. Used in a situation where you define a function with an unknown number of arguments: function a ( ... $args ) {

What is WSL?

WSL is a Windows Subsystem for Linux. It allows to run Unix-like operating systems under Windows.

When to use the CSS flexbox's 'flex-base' property?

When the container's element has a specific width and you want to ignore it and start the growth from 0px.

What is setImmediate( ) used in Node.js?

When you want to execute some piece of code asynchronously, but as soon as possible. Any function passed as the setImmediate( ) argument is a callback that's executed in the next iteration of the event loop.

What is controlled component in React?

With a controlled component, every state mutation will have an associated handler function. This makes it straightforward to modify or validate user input. For example, an input with onChange is considered a controlled component because changes are controlled through a callback function.

Why use custom hooks in React?

With custom hooks we can share functionality across several components. A custom hook is just a function that contains this functionality.

How to safely use superglobals in PHP?

You should always sanitize before using global variables, since they can by loaded with malicious code! $message = htmlentities( $_GET['message'] );

In CSS flexbox, which property of the container aligns it's elements in cross axis?

align-items

How to create a new environment in Conda?

conda create --name myenvname python=3.7

How to see all environments in Conda?

conda env list

How to see all installed Python packages with Conda?

conda list

In Npde which package to use for working with environment vars?

dotenv

In MongoDB name the CRUD functions (operators)?

insertOne( ) or insertMany( ) findOne( ) or findMany( ) updateOne( ) or updateMany( ) // with $set replaceOne( ) or replaceMany( ) deleteOne( ) or deleteMany( )

What is SASS?

is an extension language for CSS. With Sass, you can write clean CSS code and solve the common repetition and maintenance challenges present in traditional CSS. Sass must first be converted, or compiled, to CSS before the browser can directly understand it.

In CSS flexbox, which property of the container aligns it's elements in main axis

justify-content

How to get a list of all old versions or the NPM packages in a project?

npm outdated

How to get all environment variables printed to the terminal?

printenv

Name the parts of a URL:

protocol // domain name / resource protocol // ip address : port number

How to switch to an environment (say ai37) in Conda?

source activate ai37

With what datatypes substring( ), slice( ), and splice( ) work?

substring( ) works with strings only slice( ) works with strings and arrays splice( ) works with arrays only

What is default type of the <button> tag in HTML?

type="submit" By default it will make a GET request to the server.

In package.json package releases what ^ and ~ symbols mean?

~ means only update patch releases ^ means minor and patch releases [ symbol major-release . minor-release . patch-release ]

What is the maximum size of a document in MongoDB?

16 MB

Using Git, how to make sure that all remote branches are synchronized with local?

> git fetch

What is a function in JavaScript?

A function is a block of statements that perform a task or calculate value. It may or may not have an input parameters and return statement.

What is a data warehouse?

A repository for data from many different databases.

What is a shader in the WebGL context?

A shader is a program, written using the OpenGL ES Shading Language (GLSL), that takes information about the vertices that make up a shape and generates the data needed to render the pixels onto the screen (the positions of the pixels and their colors).

In Express, where to do validation step?

Always do as much as possible in the middleware section.

What is an array in JavaScript?

An array is a global object that is used to store ordered list of elements.

What is an object in JavaScript?

An object is a collection of properties which are key-value pairs.


Set pelajaran terkait

APUSH Summer Assignment Quiz Review

View Set

MH Ch 10 Stress Responses and Stress Management

View Set

Retirement and Other Insurance Concepts Questions

View Set

ITD 3443 Network Security Mid Term - Ch1- Ch7

View Set

Continuous Renal Replacement Therapy (CRRT)

View Set

BCHM 3050 : Chapter 2 - Weak Interactions in an Aqueous Environment

View Set

Identifying statements about a poem

View Set

Neuro Practice Questions Chapters 41-45

View Set