Blog post 303
I usually have something really metaphorical and wordy, but today I just feel like getting straight to the point… we all have our days, right?
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?
It should return a 400 status code because it would be a client-side error rather than a server-side (500 status codes are big yikes). 409 is the conflict code, meaning the response would conflict with the structure of the database
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?
Flexbox and media queries all the way!
When should you npm and when should you yarn?
Honestly , from what i’m gathering, it comes down to the preference of the user. They are both package managers, but it seems lie Yarn was created by facebook to make up for some of NPMs short cummings. Yarn is faster, because it installs from multiple packages at once while NPM only installs in a sequencial process relying on packages to run successfully before instillation of the next. If one package is not successfully installed in NPM it will not move on to the next one. Also the CLI of Yarn seems less jumbled and yarn lists lisences in alphabetical order… but still, it’s a matter of personal preference
How can you make sure your dependencies are safe?
You can run security audits on your dependencies to see the vulnerabilities by using npm audit in node. This will tell you the the severity of how vulnerable the package actually is and a patch option if applicable.
What are the differences between CHAR and VARCHAR data types (MySQL)?
CHAR is set to a fixed length of data characters while VARCHAR is variable length up to 65,353 characters
How else can the JavaScript code below be written using Node.Js to produce the same output?
console.log(“first”);
setTimeout(function() {
console.log(“second”); }, 0);
console.log(“third”);
// Output:
// first
// third
// secondMy response would be: console.log(“first”);
setImmediate(() => {
console.log(“second”); });
console.log(“third”);