Misc Flashcards

1
Q

Triggering a download when clicking a link

A

a:href=:download=:target=

href points to the file to download;

download triggers download in some cases, and defines the name of the, it declares the download intent;

target attribute when pointing to _blank, causes the file to be downloaded when paired with download attribute, otherwise it causes the file to open in another tab/window.

Using download + target covers most download trigger scenarios

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

Yarn vs Npm main differences

A

Yarn is faster (parallel installation);

Yarn can cache packages to install projects faster;

Yarn locks down dependecies versions by default, making installing the same project in multiple places more stable;

Yarn doesnt work with any older version of npm (5?).

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

adding, deleting modules in Yarn vs Npm, updating dependencies

A
npm install x
yarn add x
npm/yarn remove x
yarn upgrade
npm update
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

HTTP vs HTTPS

A
HTTP = hyper text transfer protocol
S = secure, makes your connection encrypted
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is it important to set inputs names in forms?

A

Not only to handle them with JS, but to send a properly named body buffer to the server ex: message=something

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

How and why access the vscode debug tools

A

Pressing F5, allows you to place breakpoints, see variable contents in real time, and track variables along the execution of a program.

Its also possible to write code while on a breakpoint in the debug mode

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

Debug doesnt offer you a terminal that is not the debug terminal, and you have to manually go to the starting point everytime you want to debug, how to fix that?

A

Creating a launch.json file in a .vscode folder: debug>add configuration, adding the ‘console’ option and setting the preferred console, and changing the “program” property to the entrypoint of your application.

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

Can you change variables in your code on the fly with vscode debugger?

A

Yes

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

Option to set the default runtime tool when debugging your code with vscode inside launch.json

A

“runtimeExecutable”: “[node | nodemon]”

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

What is MVC

A

MVC stands for model, view, controller

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
consider this code:
const products = {...};
class product{
  constructor(t){
      this.title = t;
   }
  static const findCheapest(){
      var cheapest = products[0];
      for (item in products){
            if (item.price < cheapest.price) cheapest = item.price;
      }
      return cheapest;
  }
}
Router.get('/findProducts', (req, res) => {
     const cheapest = product.findCheapest();
     res.render('/product', {product: cheapest});
});

How would you separate it between a model, a controller, and a route file?

A

model:

const products = {…};

class product{
  constructor(t){
      this.title = t;
   }
  static const findCheapest(){
      var cheapest = products[0];
      for (item in products){
            if (item.price < cheapest.price) cheapest = item;
      }
      return cheapest;
  }
}

route:

Router.get(‘/findProducts’, controllerFunction);

controller:

req, res) => {
     const cheapest = product.findCheapest();
     res.render('/product', {product: cheapest});
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the main reason to use string to represent keys and values in json?

A

main reason according to json creator douglas crockford, is to avoid reserved words in multiple languages.

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