Blog Post 303

Jayswilder
2 min readSep 20, 2020

Stuff to know

  1. If a user attempts to create a resource that already exists — for example, an email address that’s already registered — what HTTP status code would you return?
    Error code 409:The request could not be completed due to a conflict with the current state of the target resource. This code is used in situations where the user might be able to resolve the conflict and resubmit the request.
  2. Consider a responsive site design that requires a full-width image in all responsive states. What would be the correct way to code this to ensure the page loads the smallest image required to fill the space?
    The latest specification of the <picture> element is the result of years of debate on how to make images adapt. It gives authors semantic ways to group multiple versions of the same image, each version having technical characteristics that make it more or less suitable for a particular user. The new specification has achieved broad consensus and is being implemented in Chrome, Opera and Firefox and Edge.
  3. When should you npm and when should you yarn?
    If you have a lot of packages to install you may want to use yarn as it’s faster and can process multiple packages at once. If you’re using Yarn for a project and you run into problems, you can always switch back to npm and reinstall your packages with little trouble.
  4. How can you make sure your dependencies are safe?
    Read the package’s page on npmjs.com and look at who published the package, the number of versions and the number of weekly downloads. If these numbers are very low, I would pass or definitely inspect the source code. Another thing, to pay attention is when you type the package name. Typo squatting is possible and there are published packages which have names close to popular packages. In terms of how secure is NPM (the registry), they do periodic penetration testing and outgoing code reviews. Also, they report vulnerabilities to package authors and handle vulnerabilities reports from other users. But, it’s a continuous fight against spammers, malware, etc.
  5. What are the differences between CHAR and VARCHAR data types (MySQL)?
    VARCHAR is variable length, while CHAR is fixed length. CHAR is a fixed length string data type, so any remaining space in the field is padded with blanks. CHAR takes up 1 byte per character. … VARCHAR is a variable length string data type, so it holds only the characters you assign to it.
  6. How else can the JavaScript code below be written using Node.Js to produce the same output?
// Original Code Block:console.log("first"); 
setTimeout(function() {
console.log("second"); }, 0);
console.log("third");
// Alternative (node.js):console.log(“first”);
setImmediate(() => {
console.log(“second”);
});
console.log(“third”);

6. How else can the JavaScript code below be written using Node.Js to produce the same output?
```console.log(“first”);
setImmediate(() => {
console.log(“second”);
});
console.log(“third”);```

--

--