Js Engine Flashcards

1
Q

ReferenceError vs. TypeError

A

ReferenceError: is scope resolution-failure related.
The ReferenceError object represents an error when a variable that doesn’t exist (or hasn’t yet been initialized) in the current scope is referenced.

TypeError: If a variable is found (successful scope resolution), but you try to do something impossible with its value, for example, you tried to execute the variable as a function, but it is a number, then TypeError will be called by Engine.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Namespace

A

JavaScript namespace is a concept of adding classes, methods, variables, and objects inside a container. It is a programming paradigm that is utilized for assigning scope to the identifiers, such as variables and functions name. Javascript namespace assists in preventing the collision between the same name variables and functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Expression

A

An expression is a valid unit of code that resolves to a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Statement

A

A statement is an instruction to perform a specific action. Such actions include creating a variable or a function, looping through an array of elements, evaluating code based on a specific condition etc. JavaScript programs are actually a sequence of statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

node-fetch

A

minimal code for a window.fetch compatible API on Node.js runtime.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

polyfill

A

A polyfill is a piece of code (usually JavaScript on the Web) used to provide modern functionality on older browsers that do not natively support it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The Jest Object

A

The jest object is automatically in scope within every test file (not applicable to typescript?). The methods in the jest object help create mocks and let you control Jest’s overall behavior. It can also be imported explicitly by via import {jest} from ‘@jest/globals’.

INFO
The TypeScript examples from this page will only work as documented if you explicitly import Jest APIs:

import {expect, jest, test} from ‘@jest/globals’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

TypeScript Casting

A

Casting is the process of overriding a type.
Casting doesn’t actually change the type of the data within the variable.

[Using the ‘as’ keyword ]
let x: unknown = ‘hello’;
console.log((x as string).length);

[Using the ‘<>’(will not work with TSX)]
let x: unknown = ‘hello’;
console.log((<string>x).length);</string>

https://instil.co/blog/typescript-testing-tips-mocking-functions-with-jest/
https://stackoverflow.com/questions/54165536/typescript-function-return-type-based-on-input-parameter
https://dev.to/ruizb/function-purity-and-referential-transparency-7h1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

the constructor() method

A

The constructor method is a special method of a class for creating and initializing an object instance of that class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

The super keyword

A

The super keyword is used to:
- Access properties on an object literal or class’s [[Prototype]];

  • Invoke a superclass’s constructor.
    In the constructor body of a derived class (with extends), the super keyword may appear as a “function call” (super(…args)), which must be called before the this keyword is used, and before the constructor returns. It calls the parent class’s constructor and binds the parent class’s public fields, after which the derived class’s constructor can further access and modify this.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Function.prototype.bind()

A

bind is a method on the prototype of all functions in JavaScript. It allows you to:
**Create a new function from an existing function, change the new function’s this context,

and provide any arguments you want the new function to be called with. The arguments provided to bind will precede any arguments that are passed to the new function when it is called. No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

the static keyword of a class

A

The static keyword defines a static method or property for a class, or a static initialization block.

Neither static methods nor static properties can be called on instances of the class. Instead, they’re called on the class itself.

Static methods are often utility functions, such as functions to create or clone objects, whereas static properties are useful for caches, fixed-configuration, or any other data you don’t need to be replicated across instances.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

HTTP

A

Hypertext Transfer Protocol (HTTP) is an application-layer protocol for transmitting hypermedia documents, such as HTML.

  • It was designed for communication between web browsers and web servers, but it can also be used for other purposes.
    -HTTP follows a classical client-server model, with a client opening a connection to make a request, then waiting until it receives a response.
  • HTTP is a stateless protocol, meaning that the server does not keep any data (state) between two requests.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

REST

A

REST is a software architectural style

REST is not a protocol, but a set of architectural constraints.

(For a web service to be truly RESTful, it must adhere to the following constraints: )

  • Stateless. Web servers don’t keep track of previous communication. Every client request must contain the details needed to complete itself effectively.

**No client context shall be stored on the server between requests. The client is responsible for managing the state of the application.

  • Layered system. Client calls and server responses pass through several intermediary layers.
    **REST allows you to use a layered system architecture where you deploy the APIs on server A, and store data on server B and authenticate requests in Server C, for example. A client cannot ordinarily tell whether it is connected directly to the end server or an intermediary along the way.
  • Client-Server. REST imposes the client-server design pattern to enforce the separation of concerns. The client app should only know the requested resource’s URI (Uniform Resource Identifier). The server application should only return the appropriate response and be unconcerned about the frontend UI.
    **This constraint essentially means that client applications and server applications MUST be able to evolve separately without any dependency on each other. A client should know only resource URIs, and that’s all. Today, this is standard practice in web development, so nothing fancy is required from your side. Keep it simple.
  • Cacheable. Clients (and intermediaries) must be able to cache resources. Every response should define itself as cacheable or non-cacheable.
  • Uniform interface. There are several guiding principles: individual resources are identified in requests using URIs as identifiers, clients can manipulate resources through representations, messages should be self-descriptive (include enough information about how to process them), and HATEOAS.
    **A resource in the system should have only one logical URI, and that should provide a way to fetch related or additional data. It’s always better to synonymize a resource with a web page.
  • Code on demand (optional). Servers can temporarily extend or customize the functionality of a client by transferring executable code.
    usly.

When to use REST
REST is ideal for:

Applications that need to perform actions on resources (e.g. retrieve, update) on an occasional, ad-hoc basis.

Request-driven, non-realtime, and stateless systems.

CRUD operations.

Cloud apps, microservices, and web apps.

https://restfulapi.net/rest-architectural-constraints/#layered-system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

CRUD

A

create, read, update, and delete (CRUD) are the four basic operations of persistent storage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

WebSocket

A

WebSocket is a realtime protocol that enables full-duplex, bidirectional communication between a web client and a web server over a persistent, single-socket connection.

Similar to HTTP, WebSocket works on top of TCP. Unlike HTTP, WebSockets are stateful. They’re suitable for event-driven apps and services that require high-frequency, low-latency communication between client and server. Use cases include live chat, realtime dashboards, streaming live score updates, multi-user document collaboration, multiplayer gaming, and many more.

We can broadly group WebSockets use cases into two distinct categories:

  • Realtime updates, where the communication is unidirectional, and the server is streaming low-latency (and often frequent) updates to the client. Think of live score updates or alerts and notifications, to name just a few use cases.
  • Bidirectional communication, where both the client and the server send and receive messages. Examples include chat, virtual events, and virtual classrooms (the last two usually involve features like live polls, quizzes, and Q&As). WebSockets can also be used to underpin multi-user synchronized collaboration functionality, such as multiple people editing the same document simultaneously.

https://ably.com/topic/websocket-vs-rest#:~:text=WebSockets%20have%20a%20low%20overhead,%2C%20delete%2C%20or%20update%20resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Transmission Control Protocol (TCP)

A

TCP stands for Transmission Control Protocol.

It is a transport layer protocol that facilitates the transmission of packets from source to destination. I

t is a connection-oriented protocol that means it establishes the connection prior to the communication that occurs between the computing devices in a network.

This protocol is used with an IP protocol, so together, they are referred to as a TCP/IP.

https://www.khanacademy.org/computing/computers-and-internet/xcae6f4a7ff015e7d:the-internet/xcae6f4a7ff015e7d:transporting-packets/a/transmission-control-protocol–tcp

https://www.geeksforgeeks.org/what-is-transmission-control-protocol-tcp/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Referencial transparency

A

Referential transparency is the ability to replace an expression with its result, without changing the meaning/behavior of the program.

For functions, we can represent this property as a mapping between the “function reference + its inputs” and “its output”.

We can use the referential transparency property for optimization purposes (both developers and compilers), such as using lazy evaluation, memoization, or parallelization.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Function purity

A

A function is considered pure if it does not have any side effects.

In other words, given some input, a function will always return the same output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Node.js fs.readFile() Method

A

The fs.readFile() method is an Node.js inbuilt method which is used to read the file. This method read the entire file into buffer. To load the fs module we use require() method. For example: var fs = require(‘fs’);

  1. The simplest way to read a file in Node.js is to use the fs.readFile() method, passing it the file path, encoding and a callback function that will be called with the file data (and the error):
    const fs = require(‘fs’);

fs.readFile(‘/Users/joe/test.txt’, ‘utf8’, (err, data) => {
if (err) {
console.error(err);
return;
}
console.log(data);
});

  1. The promise-based fsPromises.readFile() method offered by the fs/promises module:
    const fs = require(‘fs/promises’);

async function example() {
try {
const data = await fs.readFile(‘/Users/joe/test.txt’, { encoding: ‘utf8’ });
console.log(data);
} catch (err) {
console.log(err);
}
}
example();

  1. the synchronous version fs.readFileSync():

https://nodejs.dev/en/learn/reading-files-with-nodejs/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

require

A

Node.js follows the CommonJS module system, and the builtin require function is the easiest way to include modules that exist in separate files. The basic functionality of require is that:

** It reads a JavaScript file, executes the file, and then proceeds to return the exports object.

The rules of where require finds the files:
- If the file doesn’t start with “./” or “/”, then it is either considered a core module (and the local Node.js path is checked), or a dependency in the local node_modules folder.

  • If the file starts with “./” it is considered a relative file to the file that called require.
    If the file starts with “/”, it is considered an absolute path.

Extra note: if the filename passed to require is actually a directory, it will first look for package.json in the directory and load the file referenced in the main property. Otherwise, it will look for an index.js.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

TypeScript async await

A

Modern JavaScript added a way to handle callbacks in an
// elegant way by adding a Promise based API which has special
// syntax that lets you treat asynchronous code as though it
// acts synchronously.

// Like all language features, this is a trade-off in
// complexity: making a function async means your return
// values are wrapped in Promises. What used to return a
// string, now returns a Promise<string>.</string>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What happens when you type a URL into your browser?

A
  1. You type a URL in your browser and press Enter
    ** https:// is the scheme. HTTPS stands for Hypertext Transfer Protocol Secure. This scheme tells the browser to make a connection to the server using Transport Layer Security, or TLS. TLS is an encryption protocol to secure communications over the Internet.
  2. Browser looks up IP address for the domain??
    ** does this by looking up the domain, jennapederson.dev, to find the address.
  3. Browser initiates TCP connection with the server

4.Browser sends the HTTP request to the server

  1. Server processes request and sends back a response
  2. Browser renders the content
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

DNS

A

Domain name system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

V8 (JavaScript engine)

A

V8 is a JavaScript engine developed by the Chromium Project for Google Chrome.

It has also been used on the server side, for example in Couchbase and Node.js.

V8 compiles ECMAScript directly to native machine code using just-in-time compilation before executing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Call Stack

A

call stack is a data structure which records where in the program we are.

If we step into a function, we put something on to the stack, if we return from a function, we pop off the top of the stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

heap

A

memory allocation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

AJAX

A

AJAX is a technique for accessing web servers from a web page.

AJAX stands for Asynchronous JavaScript And XML.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

setTimeout

A

setTimeout is not a guaranteed time to execution, it’s a minimum time to execution,
just like setTimeout zero doesn’t run the code immediately it runs the code next‑ish

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Instant HTML Boilerplate in VSCode With Emmet

A
  • Create an empty index.html document.
  • Place the cursor inside the html editor content and type ‘ ! ‘
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

parseInt()

A

console.log(parseInt(‘11’)) // => 11

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Debounce vs. Throttle

A
  • Debounce needs to wait for a delay between inputs in order to trigger - Debouncing works by delaying our function call by a set period of time. If nothing happens during that time then the function will run just like normal, but if something happens that causes the function to be called again during the delay then the delay will be restarted. (eg. autocomplete text boxes)

throttling
Debouncing and throttling are techniques that allow us to skip function execution if that function is called too many times over a certain time period.

  • Throttle will call the function passed to it every time the delay ends as long as the trigger for the function is still happening. Throttle is ideal when you want to group multiple events into one event on a periodic basis.
    Every time the delay ends you will get updated information on the event. (eg. resizing elements, drag and drop, scrolling, or other events that occur many times and you want to get updated on their values periodically )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

Shortcut for adding a div with a class name

A

.<name></name>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

1fr

A

1 fraction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

1rem

A

rem stands for root em

  • the em unit means “my parent element’s font-size”
  • the rem unit means “The root element’s font-size”

Use rem for Global Sizing; Use em for Local Sizing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

.grid {
width: 100%;
display: grid;
gap: 1rem; //same size of root element’s font-size
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
grid-auto-rows: 200px; //specifies the size of an implicitly-created grid row track or pattern of tracks
}

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

.box {
min-width: 100px;
width: 75%;
max-width: 500px;
}

//shorthand version
.box{
width: clamp(100px, 75%, 500px)
font-size: clamp(0.75rem, 1.5vm, 2rem);
}

A

clamp can also used for font-size

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

DNS lookup

A

Domain Name System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

race condition, dead lock

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

neural network

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

MapReduce or Hadoop

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

hired.com; triplebyte?? assessment?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

https://resumeworded.com

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Use T3 instead of Create React App

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Runtime vs. Compile Time

A

Compile time is the period when the source code written using high-level language is converted to browser-executable code;
Runtime is the period of time when a program is running and generally occurs after compile time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

Netlify/AWS Lambda serverless functions

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Mongoose

A

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports Node.js and Deno (alpha)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

Prima

A

Next-generation Node.js and TypeScript ORM(Object–relational mapping)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

WebSocket handshake

A

The handshake starts with an HTTP request/response, allowing servers to handle HTTP connections as well as WebSocket connections on the same port. Once the connection is established, communication switches to a bidirectional binary protocol which does not conform to the HTTP protocol.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Action verbs

A

Harness, fine-tune

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Git

A

Git is a distributed version control system

In software development, distributed version control (also known as distributed revision control) is a form of version control in which the complete codebase, including its full history, is mirrored on every developer’s computer.[

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

regular expression

A

A regular expression (shortened as regex or regexp) is a sequence of characters that specifies a search pattern in text.
Usually such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings,

or for input validation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

API

A

An API or Application Programming Interface is a messenger or a middleman that lets computer programs securely access data from one another.

The API works as follows:

  1. The client places a request from their device, using the
    HTTP GET, PUT, POST, or DELETE methods.
    The request is sent via HTTP to the URI (Uniform Resource Identifier). The requests include the request method, headers, and body—for example, in XML, JSON, or other formats.
  2. If the request is not valid, the API will not call the program but return an error.If the request is valid, the API makes a call to the required service.
  3. Once the API receives the response from the service, it sends the response back to the requesting application (client) via HTTP.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

GraphQL

A

GraphQL (Graph Query Language) is a fast, stable, and flexible query language and runtime.

With GraphQL, developers can construct requests to pull the necessary data from multiple sources in a single call. The response contains only what is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

Vercel

A

Vercel Inc., formerly Zeit, is an American cloud platform as a service company.
The company maintains the Next.js web development framework.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

OOP

A

Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic. An object can be defined as a data field that has unique attributes and behavior.

Abstraction, encapsulation, inheritance, and polymorphism are four of the main principles of object-oriented programming.

Abstraction lets us selectively focus on the high-level and abstract way the low-level details.

Inheritance is about code reuse, not hierarchies.

Encapsulation keeps state private so that we can better enforce business rules, protect model invariants, and develop a single source of truth for related data and logic.

Polymorphism provides the ability for us to design for dynamic runtime behavior, easy extensibility, and substitutability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Next.js has two forms of pre-rendering:

A

Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page.

  • Static Generation (Recommended): The HTML is generated at build time and will be reused on each request.
  • Server-side Rendering: The HTML is generated on each request.
58
Q
  1. https://www.usebraintrust.com/
  2. https://www.dice.com/
  3. https://www.quantum.ca/home.php - Agency in Canada, I worked with them before. Their hourly pay is pretty good (I did this with no experience out of school, $40 hourly as contractor)
  4. https://www.sisystems.com/ - another agency one of coworker developers got their role
A
59
Q

PostgreSQL

A

PostgreSQL is an advanced object-relational database management system that uses Structured Query Language (SQL) in addition to its own procedural language, PL/pgSQL.

60
Q

ElephantSQL

A

ElephantSQL is a PostgreSQL database hosting service.

ElephantSQL will manage administrative tasks of PostgreSQL, such as installation, upgrades to latest stable version and backup handling.

ElephantSQL is also integrated to several cloud application platforms (also known as PaaS).
With a click of a button your database is provisioned in the same data center as your application is hosted, and is ready to be used immediately.

61
Q

CI/CD

A

CI/CD or CICD is the combined practices of continuous integration and continuous delivery or continuous deployment.

62
Q

Element.classList

A

Using classList is a convenient alternative to accessing an element’s list of classes as a space-delimited string via element.className.

Example:
const month = document.createElement(‘div’);
month.setAttribute(‘id’, newID());
month.classList.add(‘month’);

63
Q

SSL & TLS

A

SSL stands for Secure Sockets Layer;

TLS (Transport Layer Security) is just an updated, more secure, version of SSL.

HTTPS (Hyper Text Transfer Protocol Secure) appears in the URL when a website is secured by an SSL certificate.

64
Q

CSV file

A

A CSV file or “Comma Separated Value” file is used to store data.

65
Q

Open graph protocool (og)

A

https://ogp.me/

66
Q

My Techtalk link

A

https://youtu.be/jGw2Kl-1mAo

67
Q

<ol>
<ol>
</ol></ol>

A
68
Q

css reset

A

The goal of a reset stylesheet is to reduce browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on.

69
Q

css rule

A

a CSS rule consist of selectors and a declaration block (with property-value pairs)

70
Q

CSS inheritance

A
71
Q

CSS descendent/sibling selectors

A

descendent selector:
ul ul a{
color:red
}

parent-child(immediate children) selector:

// ul.nested means ul with the nested class
ul.nested > li{
color: red
}

// List items that are children of a class of nested, which is descended from a ul.
ul. nested > li {
color: red}

//only works for ‘younger’ siblings (all the lis comes after a li)

General sibling selector:
ul.nested ol li ~ li{
color: green
}

Adjacent sibling selector:
ul.nested ol li + li{
color: green
}

72
Q

Attributes are properties on HTML element (e.g., href, title, etc.)

Attribute selector?

A

/simple attribute value/
[title] {
background-colour: green
}

/exact attribute value/
[title=’abc’] {
background-colour: green
}

/arbitrary substring attribute value/
[title*=’abc’] {
background-colour: green
}

73
Q

^ caret
~ tilde

A
74
Q

control + command + space to pull up emojis

A
75
Q

font awesome.com

A
76
Q

npm vs. npx

A
  • the command npm is used to download JavaScript packages (third-party libraries) from Node Package Manager;
  • npx is used to execute JavaScript packages downloaded this way. (Packages that are not found will first be downloaded and then run.)

//Without npx:

npm install create-react-app
node ./node_modules/create-react-app/index.js myreactapp

//With npx:

npx create-react-app myreactapp
(This command will execute the NPM package create-react-app with the name argument myreactapp, creating a bare-bones React app in the subdirectory myreactapp:)

77
Q

ESM

A

ECMAScript modules are the official standard format to package JavaScript code for reuse. Modules are defined using a variety of import and export statements.

https://webpack.js.org/glossary/

78
Q

Questions for Kyle

A

1 Payloads must be provided in JSON format;

2.//no warning if module is not found. Why? (+layout page)

79
Q

declarative vs. imperative code

A

Imperative code focuses on writing an explicit sequence of commands to describe how you want the computer to do things;

Declarative code focuses on specifying the result of what you want.

80
Q

DOM API

A

Document Object Model

  • Each HTML page is parsed by the browser and turned into a DOM of the page, which is a tree-like structure that represents HTML elements as JavaScript objects with many properties and methods.

– We can get programmatic access to the “main DOM object” via the globally available ‘document’ variable.

  • Nodes are simply nested objects inside the “main DOM object”.
81
Q

The Svelte compiler

A

The compiler takes in .svelte files, parses them into an AST (Abstract Syntax Tree), analyzes the tree, and generates Javascript and CSS.

  1. The first step is to parse the document and create 3 buckets for tags:
     tags, <style> tags, and visual (mark-up) tags (everything else):</style>
    • Parsing CSS: The <style> tags are parsed out so that we can add a unique prefix to each CSS rule avoid clashing with CSS rules defined in other components.</style>
    • ?? Parsing JavaScript: Svelte parses the
       tags to extract exports statements (which are props) and to find reactive statements.The JavaScript source code is turned into AST using the acorn package.
  • Parsing visual tags( <h1>, <p>, etc..): This gives us the complete tree of our HTML document, which we’ll use to generate the equivalent JavaScript code.

https://dev.to/joshnuss/svelte-compiler-under-the-hood-4j20

82
Q

hydration

A
  • filling with data;
83
Q

Svelte - tradeoff of pre-rendering

A

Prerendering (similar to SSG in Next.js ??) means computing the contents of a page at build time and saving the HTML for display.

tradeoff is that the build process is more expensive and prerendered content can only be updated by building and deploying a new version of the application.

84
Q

Different definition of SSG

A

Svelte: Static Site Generation (SSG) is a term that refers to a site where every page is prerendered.

85
Q

Svelte SSR + CSR

A

Normally, SvelteKit renders your page on the server first and sends that HTML to the client (SSR) where it’s hydrated (using JS). If you set SSR to false, it renders an empty HTML ‘shell’ page instead.

Ordinarily, SvelteKit hydrates your server-rendered HTML into an interactive client-side-rendered (CSR) page (checking that the DOM is in the expected state and attaching event listeners ?? ).

“By default, SvelteKit will render (or prerender) any component first on the server and send it to the client as HTML. It will then render the component again in the browser to make it interactive in a process called hydration. For this reason, you need to ensure that components can run in both places. SvelteKit will then initialize a router that takes over subsequent navigations.”

Hydration - Svelte components store some state and update the DOM when the state is updated. When fetching data during SSR, by default SvelteKit will store this data and transmit it to the client along with the server-rendered HTML. The components can then be initialized on the client with that data without having to call the same API endpoints again. Svelte will then check that the DOM is in the expected state and attach event listeners in a process called hydration. Once the components are fully hydrated, they can react to changes to their properties just like any newly created Svelte component. In SvelteKit, pages will be hydrated by default, but you can turn off JavaScript with the csr = false page option.

‘render different parts of your app: on the server with SSR; in the browser with client-side rendering; or at build-time with pre-rendering;’

86
Q

Next.js - Two Forms of Pre-rendering

A

Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in ++when++ it generates the HTML for a page.

Static Generation is the pre-rendering method that generates the HTML at build time. The pre-rendered HTML is then reused on each request.
Server-side Rendering is the pre-rendering method that generates the HTML on each request.

87
Q

CommonJS vs. ECMAScript

A

ECMAScript (/ˈɛkməskrɪpt/; ES)[1] is a JavaScript standard intended to ensure the interoperability of web pages across different browsers.[2] It is standardized by Ecma International in the document ECMA-262.

ECMAScript is commonly used for client-side scripting on the World Wide Web, and it is increasingly being used for writing server-side applications and services using Node.js and other runtime environments.

https://www.knowledgehut.com/blog/web-development/commonjs-vs-es-modules

https://v8.dev/features/modules#other-features

88
Q

Babel

A

Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.

89
Q

Classic scripts vs. module scripts in JavaScript

A

A module script is one that contains an ES6 module, i.e. it uses (or: can use) import and export declarations.

Modules are singleton. They will be loaded and executed only once.
Modules can use import and export.
Modules are always executed in strict mode.
All objects (class, const, function, let, or var) are private unless explicitly exported.
The value of this is undefined at the outer scope (not window).
Modules are loaded asynchronously.
Modules are loaded using CORS. see Access-Control-Allow-Origin: *.
Modules don’t send cookies and authentication info by default. See crossorigin=”use-credentials”.
Imports are resolved statically at load time rather than dynamically at runtime.
HTML comments are not allowed.
Share
Improve this answer
Follow

90
Q

Dev feed-back loop during development

A
91
Q

“localStorage is not defined” error showing

A

When you’re rendering on the server, you do not have a browser and thus you do not have access to all the APIs that the browser provides, including localStorage.

In JavaScript code that is running both on the server and on the client (browser), it is common practice to guard against with an if clause that checks if window is defined. “Window” is the root object provided by the browser for all the APIs that are provided by the browser.

Example:

if (typeof window !== ‘undefined’) {
console.log(‘we are running on the client’)
} else {
console.log(‘we are running on the server’);
}

92
Q

Hydration

A

https://youtu.be/D46aT3mx9LU

93
Q

Serialization

A

Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.

94
Q

JavaScript object time complexity

A

O(1) lookup
O(1) insertion

95
Q

const http = require(“http”)

A

In order to support the full spectrum of possible HTTP applications, the Node.js HTTP API is very low-level. It deals with stream handling and message parsing only. It parses a message into headers and body but it does not parse the actual headers or the body.

96
Q

-socket.IO-

different emits

A

io.on(“connection”, (socket) => {
console.log(io.of(“/”).adapter);
socket.on(“joinRoom”, ({ username, room }) => {
const user = userJoin(socket.id, username, room);

socket.join(user.room);

// Welcome current user
socket.emit("message", formatMessage(botName, "Welcome to ChatCord!"));  ===> emit to the newly connected user

// Broadcast when a user connects.   (everyone except the new user itself )
socket.broadcast
  .to(user.room)
  .emit(
    "message",
    formatMessage(botName, `${user.username} has joined the chat`)
  ); //emit to all connected users io.emit(.......)
97
Q

<form>
</form>

A

The action attribute defines the action to be performed when the form is submitted.

The method attribute specifies the HTTP method to be used when submitting the form data.
The form-data can be sent as URL variables (with method=”get”) or as HTTP post transaction (with method=”post”).
The default HTTP method when submitting form data is GET.

98
Q

Qs library for access url variables/queries

A
99
Q

Array.find(…);
Array.findIndex(…)

A
100
Q

Big O https://www.youtube.com/watch?v=HfIH3czXc-8

A
101
Q

TLS , SSL, HTTPS

A

https://www.youtube.com/watch?v=HfIH3czXc-8

102
Q

React re-render
https://www.grapecity.com/blogs/just-say-no-to-excessive-re-rendering-in-react

A
103
Q

DOM
console.dir(document)

A

The Document Object Model (DOM) is a programming interface for web documents.

A web page is a document that can be either displayed in the browser window or as the HTML source. In both cases, it is the same document but the Document Object Model (DOM) representation allows it to be manipulated. As an object-oriented representation of the web page, it can be modified with a scripting language such as JavaScript.

104
Q

A hash function is any function that can be used to map data of arbitrary size to fixed-size values, though there are some hash functions that support variable length output.[1] The values returned by a hash function are called hash values, hash codes, digests, or simply hashes. The values are usually used to index a fixed-size table called a hash table. Use of a hash function to index a hash table is called hashing or scatter storage addressing.

A

a hash function scrambles data to encrypt it, making it unreadable without special keys or difficult hacking techniques. While there are many types of two-way encryption, hash functions are one-way encryption, which makes them even tougher codes to crack.

In addition to enabling rapid data retrieval, hashing helps encrypt and decrypt digital signatures used to authenticate message senders and receivers.

https://www.techtarget.com/searchdatamanagement/definition/hashing

105
Q

Amazon Virtual Private Cloud (Amazon VPC)

A

Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you’ve defined. This virtual network closely resembles a traditional network that you’d operate in your own data center, with the benefits of using the scalable infrastructure of AWS.

106
Q

AWS IAM

A

An IAM role is an IAM identity that you can create in your account that has specific permissions. An IAM role is similar to an IAM user, in that it is an AWS identity with permission policies that determine what the identity can and cannot do in AWS.

107
Q

SSH vs SSL/TLS

A

https://www.ssl2buy.com/wiki/ssh-vs-ssl-tls#:~:text=Any%20time%20someone%20uses%20a,a%20site%20with%20SSL%2FTLS.&text=SSH%20is%20for%20securely%20executing,to%20establish%20a%20secure%20connection.

108
Q

In MacBook Finder, we can press Command + ↑ to access the parent folder of any item or folder.

A
109
Q

Linux

A

Linux is an operating system that evolved from a kernel created by Linus Torvalds when he was a student at the University of Helsinki.

It’s meant to be used as an alternative to other operating systems, Windows, Mac OS, MS-DOS, Solaris and others. Linux is not a program like a word processor and is not a set of programs like an office suite.

Linux is an interface between computer/server hardware, and the programs which run on it.

110
Q

What is SSH?

A

SSH or Secure Shell is a network communication protocol that enables two computers to communicate (c.f http or hypertext transfer protocol, which is the protocol used to transfer hypertext such as web pages) and share data. An inherent feature of ssh is that the communication between the two computers is encrypted meaning that it is suitable for use on insecure networks.

111
Q

how-to-fix-warning-unprotected-private-key-file-on-mac-and-linux

A

https://stackabuse.com/how-to-fix-warning-unprotected-private-key-file-on-mac-and-linux/

112
Q

Linux chmod

A

The chmod (short for change mode) command is used to manage file system access permissions on Unix and Unix-like systems.

https://superuser.com/questions/1212402/bad-owner-or-permissions-on-ssh-config-file

113
Q

sudo su

A

https://superuser.com/questions/105367/command-sudo-su

114
Q

PM2

A

PM2 is a daemon process manager that will help you manage and keep your application online 24/7

115
Q

Tutorial: Setting Up Node.js on an Amazon EC2 Instance

A

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

116
Q

What does sudo yum update do?

A

The yum update command is used to upgrade the installed packages to the latest version. The sudo apt upgrade command is used to upgrade all packages to the latest stable version. YUM allows any changes to be rolled back. Allows changes to be rolled back by specifying the version you want to downgrade to.

117
Q

Vim

A

Vim is an editor to create or edit a text file.

https://sites.radford.edu/~mhtay/CPSC120/VIM_Editor_Commands.htm

118
Q

PID

A

In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernels—such as those of Unix, macOS and Windows—to uniquely identify an active process.

119
Q

JSON

A

JSON (JavaScript Object Notation)

120
Q

Sudo

A

Sudo stands for either “substitute user do” or “super user do” and it allows you to temporarily elevate your current user account to have root privileges. This is different from “su” which is not temporary.

Unlike the similar command su, users must, by default, supply their own password for authentication, rather than the password of the target user.

121
Q

Docker volume

A

A Docker volume is an independent file system entirely managed by Docker and exists as a normal file or directory on the host, where data is persisted.

122
Q

ssh open file

A

You need to use a text editor such as nano (easy for new users) or vim. The steps are follows to open a file:

Log in using ssh:
ssh user@server-name
To show just file run:
cat /path/to/file
To edit or open a file named demo.py in the current directory, execute:
nano demo.py
vi demo.py
Other options are:
more filename
less filename

123
Q

Volatile memory

A

Volatile memory is a type of memory that loses its contents when the computer or hardware device is switched off.

124
Q

Volatile memory

A

Volatile memory is a type of memory that loses its contents when the computer or hardware device is switched off.

125
Q

Byte

A

A unit of data that is eight binary digits long is known as a byte.

126
Q

Byte

A

Computer storage is generally measured in multiples of the byte.

127
Q

Bash script

A

https://ryanstutorials.net/bash-scripting-tutorial/bash-script.php

128
Q

shell

A

In computing, a shell is a computer program that exposes an operating system’s services to a human user or other programs. In general, operating system shells use either a command-line interface (CLI) or graphical user interface (GUI), depending on a computer’s role and particular operation. It is named a shell because it is the outermost layer around the operating system.[1][2]
Command-line shells require the user to be familiar with commands and their calling syntax, and to understand concepts about the shell-specific scripting language (for example, bash), while graphical shells place a low burden on beginning computer users and are characterized as being easy to use, yet most GUI-enabled operating systems also provide CLI shells, normally for performing advanced tasks.

129
Q

Process

A

Essentially a process is a running instance of a program.

130
Q

chmod

A

In Unix and Unix-like operating systems, chmod is the command and system call used to change the access permissions and the special mode flags of file system objects. Collectively these were originally called its modes, and the name chmod was chosen as an abbreviation of change mode

131
Q

Bash

A

(Bourne-Again Shell)

132
Q

Dist folder

A

The shortform dist stands for distributable and refers to a directory where files will be stored that can be directly used by others without the need to compile or minify the source code that is being reused.

https://stackoverflow.com/questions/22842691/what-is-the-meaning-of-the-dist-directory-in-open-source-projects

133
Q

Node.js

A

Node.js is a runtime that allows you to run JavaScript on a server.

<In computing, a server is a piece of computer hardware or software (computer program) that provides functionality for other programs or devices, called “clients”.>

134
Q

npm

A

npm is a package manager for the JavaScript programming language maintained by npm, Inc. npm is the default package manager for the JavaScript runtime environment Node.js. It consists of a command line client, also called npm, and an online database of public and paid-for private packages, called the npm registry. Wikipedia
Developer(s): npm, Inc. (a subsidiary of GitHub, a subsidiary of Microsoft)

135
Q

NPM INIT

A

Create a package.json file

136
Q

Path differences in Linux

A

Linux absolute path( full path start with ‘/’):

/home/users/c/computerhope/public_html/cgi-bin

Linux relative path(The relative path begins with a dot (period), representing the current directory (also called the “working directory”)):

./public_html/cgi-bin

(path.join() simply concatenates segments and its return may or may not result in an absolute path. path.resolve() always returns an absolute path, using the target operating system’s root as the root OR first argument with a leading / as the new root.)

137
Q

Loader(webpack)

A

Loaders
Webpack enables use of loaders to preprocess files. This allows you to bundle any static resource way beyond JavaScript.

138
Q

Rule(s).test

A

Rule.test
Include all modules that pass test assertion.

139
Q

(webpack) devtool: ‘source-map’

A

-

140
Q

@babel/preset-env

A

@babel/preset-env is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, browser polyfills) are needed by your target environment(s). This both makes your life easier and JavaScript bundles smaller!

@babel/preset-env takes any target environments you’ve specified and checks them against its mappings to compile a list of plugins and passes it to Babel.

141
Q

127.0.0.1

A

127.0.0.1 is called the loopback address, and is the IP a computer uses to refer to itself.

142
Q

Hosts file

A

A hosts file is a local file stored on the computer that translates domain names or NetBIOS names into an IP addresses.

When looking up an IP address, the computer first looks at the hosts file to resolve the name. If the name is not in the local hosts file, it tries resolving using a DNS (Domain Name Service), and if also not found, the look up fails.