- 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?
409, duplicate resource
- 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?
You can set the image to fill up the entire page by setting the width to 100% or the view width, which I tend to avoid as it seems to cause me problems when scaling with other items on the page. And as far as making the image load quickly, you can lazy load it in, and once the page is fully loaded, the lazy image can be replaced with the higher resolution image.
This is a good resource https://www.sitepoint.com/five-techniques-lazy-load-images-website-performance/
- When should you npm and when should you yarn?
First it’s worth mentioning what yarn is. It is a package manager, much like npm. Think of Yarn as a new installer that still relies upon the same npm structure.
Something I keep coming back to is the yarn.lock feature, which essentially ensures that every device installs the same versions and updates. There is a similar feature with node called “shrinkwrap”, but according to this article https://www.keycdn.com/blog/npm-vs-yarn this feature is not automatically generated, and can be a bit messy, whatever that means. I should note that this article seems to be quite in favor of yarn.
That being said, it does list some drawbacks, such as it conflicting with npm in some cases, and requiring more disk space, as it much be installed locally. Some pretty minor drawbacks, with the first problem having some clever solutions.
To undo everything here, I have read other articles claiming that npm has included many of the same features as yarn, and some people prefer it. So it really just seems like preference more than anything.
- How can you make sure your dependencies are safe?
Reading the packages page info on npmjs.com. It tells you information about the author, how many downloads, the number of versions and more. All of this can give you a clue to how widely accepted the package is, and if any of the numbers are low, you might want to look closely as the source code. Ontop of that there are some packages you can install to check for malicious or outdated code.
- npm outdated
- Trace by RisingStack
If something you are installing is something that is questionably safe, never install it globally.
- What are the differences between CHAR and VARCHAR data types (MySQL)?
A CHAR field is a fixed length, and VARCHAR is a variable length field.
This means that the storage requirements are different — a CHAR always takes the same amount of space regardless of what you store, whereas the storage requirements for a VARCHAR vary depending on the specific string stored.
Will ask about this in a tutoring session, as I don’t really understand it.