386 private links
const moreInfos = { info: "Please go to the desk." }
return {
address: "20B Rue Lafayette",
postcode: "75009",
...(moreInfos !== undefined && { moreInfos })
}
In JavaScript, primitive values are Number, String, Boolean, Undefined, Symbol, and BigInt. Other data types are passed by reference, which means that the variable is given instead of just a copy. Modifications happen in-place.
An example of Weakmap: https://gist.github.com/PaulRosset/0d4e3a9b9af20f9997b41d15f70c8808#file-weak-map-js. Everything can be a key.
Clean code is not only concise code, but more importantly, it is readable. A rule of thumb when writing code, is to write code as if comments didn’t exist. The code should be self-explanatory.
- booleans should always have a prefix like "is", "has", or "was"
and other JS tips
The thing is some are already on https://1loc.dev/
Others can be added :)
- Use Nouns to represent resources / Not Verbs
- Use Pluralized Nouns for resources
- Use hyphens (-) to improve the readability of URIs
- Use forward slashes (/) for hierarchy but not trailing forward slash (/)
- Avoid using file extensions
- Version your APIs:
http://api.example.com/v1 - Use query component to filter URI collection:
http://api.example.com/v1/store/employees?department=IT®ion=USA
Git has become a complete tool. I missed a lot of it, but I am not sure I will need it as it is most of the time for big repositories.
I agree with many folks here on HN in that
nullandundefinedhave important differences.undefinedappears when you access an invalid field, whilenullappears when you access a valid, but empty field.
-
SSR and Jamstack
-
Active Memory Caching
In summary, if you want to increase the performance of your application, you can use server caches to speed up your APIs, but if you want to persist your app state, you should use the local storage cache.
- Data Event Sourcing
Useful for real-time applications. Connections are made with Websockets.
4.a Prefetching
Pros: Prefetching waits until the browser’s network is idle and is no longer in use and will stop when you trigger usage by clicking a link or triggering a lazy loading function.
Pros: Prefetching caches data within the browser, making page transitions faster when redirecting to a link.
4.b Lazy Loading
Lazy loading can only help you delay downloading resources and doesn’t make your resources smaller and more cost-efficient.
- Resumability
Essentially, Resumability uses the server to do the heavy lifting and then gives the client a minimal amount of JavaScript to execute via serialization.
:last-child, :nth-last-child(2), nth-child(2), nth-child(3n), nth-child(even), nth-child(odd), nth-child(n+3), nth-child(-n+3), nth-child(3n+1), nth-child(3n-1)
What does which operators in javascript?
TL;DR Use HTML attributes with the content: attr() CSS property.
Here is an example with a notification icon with a counter nudge.
Nano ID is nano-sized unique string ID generator for JavaScript. It’s truly small (130 bytes minified), URL-friendly, and it has no dependencies. Plus, it’s safe, secure, and fast.
Project link: https://github.com/ai/nanoid
A small library to generate unique ids. It is implemented in a lot of other languages too.
webkitdirectory multiple to allow a directory and every files in it to be uploaded :)
Minimal CSS to look great: 58 bytes, 100 bytes, and 100 more bytes.
I find it hard too :/
Rule of thumbs:
- Show errors immediately if issues are severe
- Late validation is almost always better
- Validate empty fields only on submit
- Reward early, punish late: if a user edits an erroneous field, we should be validating immediately, removing the error message and confirming that the mistake has been fixed as soon as possible (reward early). However, if the input was valid already and it is being edited, it’s probably better to wait until the user moves to the next input field and flag the errors then (punish late).
- Validate after a copy-paste
- Allow users to override inline validation
- Just in time validation
- For short forms, consider validation on submit only. For complex forms, use the task list pattern
Laravel suit l'évolution et peut être utilisé avec Vite. Ici un exemple en intégrant Boostrap.
The infer keyword only works within conditional types. It defines the type depending of another one.
Some use cases:
- extract type from promise
- extract function return type
- extract multiple candidates
Similar to useFetch in vue
A collection of algorithms. They are available in many languages.
Here a list about datastructures: https://the-algorithms.com/fr/category/datastructures