Tagged “javascript”
-
TIL what is npm Script javascript node
Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.
-
TIL fancy methods to transform Javascript Objects objects javascript mdn
You can use Object.entries(), Object.keys(), Object.fromEntries()...
-
TIL how to hide your JS code obscurity javascript encryption
ONE THING TO NOTE: Encrypting a script is stronger than obfuscation, both methods are still not adequate to protect secret content. Honestly, I don't think it's worth it on a production site, and instead just go with pure server-side if you want security. But it's fascinating.
-
TIL Why is TextEncoder a class oop javascript
My assumed answer - it was for extension. What does reddit commenters have to say about it?
-
TIL why google recommends you avoid document.write() performance javascript browser corewebvital
By injecting it with code, it bypasses the preload scanner. This means that the browser can’t request this file until it’s actually run the '<script>' block that inserts it, which is very much just-in-time (and too late).
-
TIL Using pseudo-classes in your querySelector! css javascript
let notTuna = document.querySelectorAll('.sandwich:not(.tuna)')
-
TIL using abortController to removing events mdn javascript
Trying to unhook a eventListener? Don't use `removeEventListener`, instead use AbortController.
-
TIL detecting if a user is online with JS fingerprint javascript mdn
You can use the navigator.onLine api.
-
TIL prioritizing Javascript performance javascript corewebvitals
... async and defer attributes should be used where possible to avoid render blocking of the DOM. Render blocking is when the browser must halt all rendering of the page in order to process a resource that the page depends on.
-
TIL problem with AJAX fetch javascript performance
Synchronous XHR is harmful for performance because the event loop and main thread is blocked until the request is finished, resulting in the page hanging until the data becomes available. fetch is a much more effective and efficient alternative with a simpler API, and has no support for synchronous fetching of data.
-
TIL a helper to make things uppercase javascript helper string
ucWords function converts the first character of each word in a string to uppercase. This function is the same as PHP’s ucWords function.
-
TIL the core-js spam trolling image javascript git
This entire repo is a hilarious rabbit-hole when you combine this with everyone complaining about the console spam that the dev added to it asking if anyone can find him a job. One of my favorite PRs
-
TIL Web Performance with Javascript javascript webworker performance criticaljs image
Overall, we should be loading the most important JS first to get the website working. Then load all your third-party scripts onto your web worker, which then responds with 'Success' once it loads, so you can then interact with it.
-
TIL Tagged Templates mdn javascript image
Tags allow you to parse template literals with a function. The first argument of a tag function contains an array of string values. The remaining arguments are related to the expressions.
-
TIL Multiple Fetch Requests javascript api
I've been frequently dealing with this scenario in the past few weeks. I wanted to make multiple fetch requests, and then merge everything together when it's all done. To make multiple/parallel fetch requests:
-
TIL Scoping with Cypress javascript testing cypress
So you wanted to find a specific element called `heading`. But you have a BUNCH of elements called `heading`. By using `within()` helper, you can force it to only look inside `main` elements.
-
TIL SolidJS reactivity javascript reactivity
SolidJS is a JavaScript framework that supports binding data to elements that it then syncs and displays on web pages.
-
TIL Computed Properties in Javascript naming javascript mdn
Today I learned about Computed Property names.
-
TIL if TypeScript is worth it typescript javascript
The answer: No, according to HackerNews. But HackerNews audience aren't exactly representative of average developers? From my perspective, they're the 'startup' and 'ship fast and break things' folks. (I mean, I am too!)
-
TIL delta time time javascript
Delta time, also known as 'time delta,' refers to the difference between the 'current time' and the 'last time' a piece of code was executed. In JavaScript, delta time can be calculated using the Date object or by using the performance.now() method.
-
TIL finding the browser being used javascript browser
How to detect the browser you're using, with javascript.
-
TIL Libuv javascript node
Libuv also implements two extremely important features of Nodejs which are the event loop and the thread pool and in simple terms, the event loop is responsible for handling easy tasks like executing callbacks and network I/O while the thread pool deals with heavy work like file access or compression.
-
TIL brackets breaking elements in JavaScript javascript linter
The 'automatic semicolon insertion' it does is an error correction process
-
TIL Node.js Event Emitter node javascript
This is kinda like the addEventListener() for browser javascript.
-
TIL Double Exclamation shorthand for booleans javascript booleans
JavaScript (and TypeScript) lets you convert a non-Boolean value to Boolean using the double exclamation shorthand. '!!'
-
TIL how to delete all cookies with Javascript javascript cookies
If someone selects 'Reject', you want to remove all the tracking cookies. You can easily clear all cookies stored in a web page by accessing the cookie using document.cookie and clearing it.
-
TIL Sparse Arrays array javascript
The ['Batman', , 'Bane'] array is a sparse array. See how it there is a blank?
-
TIL accessing different data attributes javascript data html
You can access it in javascript using element.getAttribute('data-sandwich'). A better way is to go with the Element.dataset property.
-
TIL Performance tests performance javascript optimization
While doing performance tests, I was curious how long a loop was running. I used the performance.now() trick.
-
TIL getting the height with Javascript javascript size css
Say you wanted the height of a element. getComputedStyle gets you that. BUT -- it may lie about it to avoid css history leak. Instead use computedStyleMap.
-
TIL not using try/catch block with promises for error catching promises javascript advanced errorcatching
You shouldn't use a try/catch block inside the Promise Definition. Your promise is already doing that.
-
TIL using proxies for reactivity proxy advanced javascript
A Proxy let you detect when someone gets, sets, or updates a property on an object, and run code when they do. But why? This usecase -- when you add/update the object, it also updates localStorage!
-
TIL AggregateError promises javascript mdn
I heard the term AggregateError in relations to 'Promise.Any', So it's several errors wrapped in a array. That's all.
-
TIL adding a helper function for CSS classes css javascript utility
I like this helper. This lets you quickly add/remove CSS classes to your elements in a easy-to-read way.
-
TIL JS Cron and process.platform node javascript cron
Cron is a tool that allows you to execute something on a schedule. This is typically done using the cron syntax. process.platform tells you what platform the user is running. For this usecase, if it's win32, use robocopy. Else use rsync.
-
TIL the new Temporal API datetime javascript proposal
Temporal is a TC39 proposal for a non-sucky date time API
-
TIL the difference between partial application and currying advanced javascript closure
Partial application transforms a function into another function with smaller set of arguments. Currying creates nesting functions according to the number of the arguments of the function. Each function receives an argument.
-
TIL the stack and heap javascript memory global
The stack is a data structure that JavaScript uses to store static data. The Heap is Dynamic memory allocation, storing objects and functions. Garbage Collection.
-
TIL loading third-party scripts onto service workers serviceworker javascript cache optimization
An alternative to self-hosting scripts would be using Service Workers to cache them. This can give you greater control over how often they are re-fetched from the network. This could also be used to create a loading strategy where requests for non-essential third parties are throttled until the page reaches a key user moment.
-
TIL about why Node was invented node history javascript
Node.js applications never buffer data, which dramatically reduces the processing time of uploading files, such as videos or audios. In other words, it simply outputs data in chunks, meaning that, for example, a user can watch videos without any interruption.
-
TIL How to implement two-way binding without a framework javascript vue codepen react data
One of the reasons we use React or Vue is because of that sweet sweet two-way binding. It's the automatic syncing of data between the model (data) and the view (UI) in both directions. Any changes made to the data will automatically update the view, and any changes made to the view will automatically update the data.
-
TIL Event Delegation javascript optimization events
Event delegation is one of the most helpful patterns for DOM events! Adding too many event listeners means JavaScript is storing it all in memory. Event Delegation lets you store one listener, that then looks for the target.
-
TIL what matters for JS optimization javascript loops memory
Optimizing your Javascript - Using getElementById() vs querySelector()? Doesn't matter. Loops? Doesn't matter. What matters: Render Blocking code, Repaints and Reflows, Memory allocation
-
TIL that the max size of a Map/Set is 26843544 javascript mdn v8 math
JS Maps and Sets are implemented by OrderedHashTable. OrderedHashTables double in size when they need to grow, and their max size is 26843544. After 16777216 elements, doubling that exceeds the max, so the allocation fails.Currently these data structures are not implemented to be usable for large in-memory datasets. Also note that the JS specification itself doesn't require that Maps and Sets must scale with available memory.
-
TIL A practical Curry Example curry advanced javascript
Currying is a programming technique where you take a function with multiple arguments, and you turn it into smaller sequential functions where you pass one argument at a time. But many use-cases kinda suck
-
TIL the difference between single-threaded & multi-threaded architecture php javascript performance
For web dev, we don't need it. We're not bottle-necked by the processing power. We're instead bottlenecked by the ability to read files/databases. We can simulate multi-threading (and improve our app's performance) using async/await.
-
TIL how outsiders see Javascript typescript javascript horror
The bane of my existence - 'SyntaxError: Cannot use import statement outside a module'
-
TIL Prototypical Inheritance vs return functions javascript proto functions
When to use proto versus return functions?
-
TIL a code snippet to check if the value is of type javascript gist
This short snippet helps us check!"
-
TIL using defer/async optimization javascript mdn
So an old and often-touted best practice for performance has been to load your JavaScript in the footer of the document to avoid render blocking of scripts. By putting it in the footer, the DOM is constructed before your scripts have a chance to run. That's dumb.
-
TIL about console.dir debug mdn javascript
If you console.log a element, you will get it's HTML markup. If you want it as a JS object, use console.dir instead
-
TIL Replace Only Fixes the First Encounter javascript mdn
Replace only finds the first occurrence. ReplaceAll fixes it all.
-
TIL Optional chaining broke his mom's site apple javascript horror
Modern browsers get all fancy new features. But what about still-working technology like 1st-gen iPads and old chromebooks that no longer get updates?
-
TIL Cherry-picking out of bootstrap-vue javascript vue
If you are using a component library that uses ES modules like bootstrap-vue, you can cherry pick its components instead of just registering all of them globally.
-
TIL Avoiding promise chains javascript promises
Callbacks are functions that are executed when another function finishes. It can lead to callback hell, which instead, use a promise! But don't make promise chains
-
TIL use-cases for Generators in Javascript advanced javascript mdn
Generators are functions that can be exited and later re-entered. Their context (variable bindings) will be saved across re-entrances.
-
TIL Memoization performance advanced javascript performance
Memorization in a nutshell: You catch the data if it exists already.
-
TIL filtering DOM elements when you web-scrape web-scraping javascript
I love web-scraping. One core technique you have to master is stripping HTML from a string.
-
TIL event bubbling javascript codepen clicks
Event bubbling is when an event is in an element inside another element, and both elements have registered a handle to that event. That cause collisions.
-
TIL about the proposed pipe operator javascript functional-programming
In functional programming, you chain functions to provide a result. Witht he Pipe operator, it can look like this: const total = money |> removeOneDollar |> addTwoDollars |> addFiveDollars
-
TIL different ways to inject content via Javascript html javascript
There's lots of ways to do things in Javascript. It gets difficult to know which way is the 'preferred' way.
-
TIL using Event Delegation javascript events
It's cheaper for the browser to track one event and fire it on every click that it is to manage multiple events.
-
TIL Why use Closures javascript freecodecamp advanced
Now you might be asking, why even use it? Why not just flatten it out so it's just one function with one return statement?
-
TIL the difference in the JS Event Loop for Browsers and Node javascript architecture
It took me years to understand this. Someone saying that 'they use Javascript' could mean they use Javascript on the web, or Node, or a different Javascript environment, of which there are MANY!
-
TIL Promise Constructor edge-case javascript async
The promise constructor has to do a few more workarounds in order to catch errors. Just use a then statement
-
TIL more Javascript Environments javascript
This is back to why Web Interop exists! Because we have a specific Javascript standard (via ECMAScript Language Specs, by the TC39), and many many different companies/businesses who implement Javascript.
-
TIL High Resolution Time gamedev javascript
The Date object is no longer the recognized method for timing events because it is very imprecise and can be modified by the system clock.
-
TIL Number formatting with Javascript numbers javascript mdn
Say you wanted to convert this into a string, with all the commas and everything. You can use the browser Intl package to use this.
-
TIL refactoring object lookups to avoid looking at the prototype chain advanced javascript refactor mdn
Depending on your lookup method, you can access the prototype chain, which opens up some potential vulnerabilities or terrible side effects!
-
TIL tips for making a API Wrapper javascript reddit
The API wrapper should do zero 'interpreting' (or as close to zero as you can get).
-
TIL about heavy.js javascript mdn
It downscales all images on your webpage by a factor of 3, takes the RGB values and creates spans with appropriate styles. Yes, this converts your images to HTML p and spans.
-
TIL about semaphores javascript advanced programming
A semaphore limits access to a resource to some number of consumers. Any new requests for the resource will get stalled until later, eventually to be handled.
-
TIL cancelling promises javascript mdn
There is a cross-platform (Node, Browsers, etc) cancellation primitive called AbortController. You can use it to cancel functions that return promises rather than promises themselves.
-
TIL the WebCrypto API javascript mdn math
If you dealing with sensitive applications and need a more secure method of randomization, I’d recommend the Crypto API. Reasons you may want to use WebCrypto include temporary verification codes, random password generation, randomized lottery numbers, etc.
-
TIL another way to prevent buttons from submitting HTML button form javascript
When you have two buttons, you can use 'type=button' to stop them from submitting a form.
-
TIL ES6 Proxy's apply method javascript mdn advanced
Using JavaScript proxies you can wrap an existing object and intercept access to its attributes or methods, even if they don’t exist. You can also redefine fundamental operations for that object.
-
TIL ES6 Proxy javascript mdn advanced codepen
Using JavaScript proxies you can wrap an existing object and intercept access to its attributes or methods, even if they don’t exist. You can also redefine fundamental operations for that object.
-
TIL about the Clipboard API javascript mdn webapi
The Clipboard API can be used to implement cut, copy, and paste features within a web application.
-
TIL how to explain Typescript like i'm 5 javascript eli5 typescript
Typescript is quickly becoming a powerful tool for Javascript developers. Typescript provides optional static typing.
-
TIL a short explainer of the Execution Context javascript javascript-advanced mdn eli5
It is an abstract concept that represents the environment in which JavaScript runs. What happens inside the execution context is two things basically. The first is parsing the code line by line and the second is storing the variables and functions into the memory.
-
TIL about this work of beautiful code cleancode javascript readability
I'm a strong believer in writing code for tomorrow's developer. I'm incredibly anti-code-golf. (It's a beautiful art form, but keep it out of production code!)
-
TIL adding an Event Listener to document javascript click performance
When an element in the DOM is clicked, the event bubbles all the way up to the parent element (the document and then the window). This allows you to listen for events on the parent item and still detect clicks that happen inside it.
-
TIL what jQuery's role is today jquery javascript
Today’s JavaScript frameworks allow us to break the UI into components, making it easier to scale up an application. It creates abstractions for easier synchronization between the data and the view. We don't need to hack the DOM element directly, and instead let the framework handle it.
-
TIL the history of jQuery jquery javascript
With the launch of jQuery in 2006, web developers were able to access and manipulate DOM and CSS faster and easier than ever before.
-
TIL obvious security vulnerabilities and prototype pollution vulnerabilities security javascript
Object-based inheritance gives JavaScript the flexibility and efficiency that web programmers have come to love – but it also makes it vulnerable to tampering. Malicious actors can make application-wide changes to all objects by modifying object, hence the name prototype pollution.
-
TIL the different Javascript Engines javascript node
There's dozens of JS engines. V8 ,Chakra, Spidermonkey, JavascriptCore Webkit, JerryScript...
-
TIL about what causes Memory leaks in Javascript javascript advanced-js memory
As long as it is possible to reach it, keep it. Everything else gets yeeted.
-
TIL JS in Google Sheets excel serverless googlesheets javascript scripting
I like this because I do use a lot of Google Sheets, and I write a lot of Javascript. And together, they can be a quite a force to be... calculated.
-
TIL how Node/V8 works with imports/exports node advanced-js javascript
This is accurate only up to how JS works in Chrome-based browsers, and NodeJS, as Node uses V8 under the hood. But overall, it's referencing vs live binding
-
TIL about Micro-frontends frameworks javascript webdev
Micro frontends are a new pattern where web application UIs (front ends) are composed from semi-independent fragments that can be built by different teams using different technologies.
-
TIL of the difference between || and ?? javascript boolean stackoverflow
The difference between || or ??
-
TIL about more examples of currying javascript advanced
Currying is nothing more than a way to transform functions that accept multiple parameters into a sequential list of functions that take only one parameter each.
-
TIL some more examples of closure javascript closure
Five benefits- Private variables and methods. Data hiding and encapsulation. Currying. Function Factories. Performance
-
TIL about Partial Hydration javascript frameworks ssr
Partial rehydration is an extension of the idea of progressive rehydration where individual pieces of a server-rendered application are 'booted up' over time. This contrasts with the approach of initializing the entire application at once.
-
TIL what Single Threaded & Non-blocking means in JS javascript advanced
Javascript is a single-threaded language. This means it has one call stack and one memory heap. Non-blocking means it'll read from top to bottom and throw anything async in the queue.
-
TIL how to create a delay snippet for JS javascript performance
We check for any user interaction. The 'eventList' array has eventlisteners, listening to those movements. Or we wait 5 seconds. Then Switch the 'delay' attribute with 'src' attribute. Run the 'cookie.js' code!
-
TIL about the element.closest() method javascript codepen eventlisteners
Using a single event listener is super efficient, but has edge-cases. So using closest instead of match.
-
TIL some JS tree traversals dom jquery javascript
Ah, DOM tree traversal. It's the adventure that keeps on giving.
-
TIL about switching out of JS Classes and into JS Modules javascript oop classes advanced
A classes are just blueprints for creating objects. A class encapsulates data and functions that manipulate data. A module is a file that exports features, such as variables, objects, and functions, that can be used elsewhere.
-
TIL about the End of Time! (for Unix) trivia datetime javascript
On January 19th, 2038 at precisely 03:14:07 UTC, instead of the clock going to 03:14:08 UTC, it will overflow and go to 20:45:52 UTC of December 13th, 1901.
-
Grouping console messages together javascript devtools
You can wrap console messages together using console.group('name') and console.groupEnd('name')
-
TIL about console.assert() javascript devtools
You can instead use console.assert() to show conditional errors
-
TIL about wrapping a variable in curly brackets devtools javascript
Output the key:value pair using curly brackets
-
TIL how to replace many characters in javascript mdn regex javascript
You can use the replace() method to swap one string pattern for another.
-
TIL about getting how long it takes for JS to execute performance javascript
This post took me 7.22 minutes to write.
-
TIL Spreading a object into another object codepen javascript
It's copying an object into another object, while also adding a new input.
-
TIL about the Broadcast Channel API javascript browser
Think of a use-case like, once you logout from an app running in a browser tab, you want to broadcast it to the app instances opened in other tabs of the same browser.
-
TIL ELI5 for Async Await javascript eli5
If you make a call to a friend across the world, it'll take 20 seconds before they respond. You can't just wait 20 seconds. So you run other code.
-
TIL that 2^24 items will cause a interesting error math javascript errors
Obviously there's not much real use-cases. But that's the fun of finding limitations.
-
TIL about the Image Capture API browser apis javascript
The Image Capture API which helps us to capture an image or grab a frame from the video devices(like webcam). Not only that, you can also perform actions on capturing an image or grabbing a frame.
-
TIL of this switch shorthand javascript
Using a switch statement to fire a function? Nah, just fire it.
-
TIL how to convert a nodeList into an array javascript browser
You can use the spread operator to turn a nodelist into an array!
-
TIL how to pass unlimited arguments to a function mdn functions javascript
The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent variadic functions in JavaScript.
-
TIL using live regions for autocomplete accessibility accessibility javascript autocomplete
However, the screen reader does not recognise this as an action to tell the user about. It will announce the header and the input box when they gain focus, but not the search results.
-
TIL how to get the location of the user with the Geolocation API mdn browser javascript permissions
You can get the user's location in the browser. First, the user has to accept this. As it's a security request. Second, you use the Geolocation API.
-
TIL of someone who missed all the JS pitfalls javascript devstory
If JS doesn't do it the way they think it works, then... JaVaScRiPT is STUPID!
-
TIL about the new Intl.NumberFormat browser API javascript browser mdn
No more stupid-ass hacks to format numbers correctly.
-
TIL more scary floats in Javascript integer javascript advanced-js
using floats with parseInt can cause unexpects side effects
-
TIL startWith mdn javascript string
Getting a boolean result of true or false, depending on if the string startsWith a specific substring
-
TIL a quick recipe involving Axios and Cheerio web-scraping javascript fetch recipe mdn
A quick recipe to http request an api and use cheerio to web-scrape it
-
TIL end all node processing scripts javascript commandline terminal bash node stackoverflow
killall node - a sure fire way to kill a node.js server that won't stop running.
-
TIL map() only when you need it javascript performance loops
The origins of 'map()' was to create methods that allow us to manipulate array data without mutating it. It's part of the whole set of methods to make functional programming easier in Javascript.
-
TIL solving the this keyword and it's execution context javascript advanced
The this keyword references the current execution context of the function from where you’re calling using it. If it's used in a regular function, a arrow function, or a method changes the execution context of this.
-
TIL converting Booleans to Numbers helpers javascript
This helper is great for APIs. Not every language parses true/false the same. But every language knows that 0 is false, and 1 is true.
-
TIL Microtask Queue vs the Call Stack Queue advanced javascript
When everything is done from the 'Call Stack', the Event Loop finds some new tasks to go after. It'll dig through all the 'Microtasks queues', then in the 'Macrotasks queues'.
-
TIL of a console.log way to avoid [object object] javascript object node
you can use JSON.stringify to get a object.
-
TIL JS Coercion javascript edge-cases ecmascript
In JavaScript, the + operator is used for both numeric addition and string concatenation. When you 'add' a number to a string the interpreter converts your number to a string and concatenates both together.
-
TIL Avoiding dependencies in your helper functions helpers javascript testing functional-programming
Impure functions for helpers? What is this... 1999?
-
TIL Find unused JavaScript javascript devtools optimization
Chrome's Coverage panel allows you to quickly locate JavaScript (and CSS) code that has — and has not — been used. To start, open Coverage from the More tools sub-menu in the DevTools menu
-
TIL checking falsy values inside an array array javascript
Using the key Boolean to find any true/false statements inside an array
-
TIL a neat way to clone and object and override the items javascript objects
Spread the object into a new object, then override the element later.
-
TIL mutations and how to sort without mutating javascript functional-programming arrays
Mutation isn't bad. It CAN cause side effects and ruin your life. There's times when you want to have your objects mutate. For everything else, switch to functional programming and passing the data.
-
TIL You can dynamically name objects javascript objects
Not all Object keys have to be hard-coded strings. To make it dynamic, use [brackets].
-
TIL adding properties conditionally using the spread syntax objects javascript conditionals
You can conditionally add properties to objects by ... in there.
-
TIL JS commas evaluate operands javascript interview tricky
The comma operator evaluates each of its operands (from left to right) and returns the value of the last operand. var a=(2,3,4,5,6,7), result is 7.
-
TIL Javascript Vs Typescript cheatsheet javascript typescript cheatsheet
A easy-to-print sheet pointing out the difference between the two.
-
TIL Adds days to a date javascript dates
Maybe you just need some quick date math, and don't want to use a date library.
-
TIL Grouping Event Handlers cleancode event-handlers javascript
Group your event handlers together for that sweet cleaner, fresher code.
-
TIL Pure and Impure Functions functional-programming javascript clean-code
A important piece of Functional Programming is creating Pure Functions. NO SIDE EFFECTS
-
TIL all functions create a empty prototype object javascript classes advanced
When you create a function in JavaScript, it automatically creates an empty container called prototype for you to stick your methods into.
-
TIL difference between document.hidden vs document.hasFocus() javascript visibility stackoverflow
Do you need to check if the tab is currently active/Visible?
-
TIL oncontextmenu feature for right-clicking javascript events
The oncontextmenu property lets us assign an event handler function when the right mouse button is clicked on the browser tab.
-
TIL writing cleaner If statements javascript cleancode ifstatements
Graphs and visual flow of various if-else statements
-
TIL Scroll to the top of the page javascript
A neat trick to create one of those 'To the top' buttons!
-
TIL toLocaleDateString that's built into Javascript for dates date javascript mdn
Date().toLocaleDateString('en-US') returns a string with a language sensitive representation of the date portion of this date.
-
TIL Event Listeners in devtools javascript events devtools
Today I learned that you can identify the Event Listener directly in the Devtools!
-
TIL CSS variable tricks css javascript variables
If you want to change the background with Javascript, you can use a CSS variable.
-
TIL more about destructuring javascript cleancode
Destructuring allows us to extract values from arrays and objects and store them in variables with a more convenient syntax.
-
TIL why NodeJS in reference to I/O javascript node definitions
Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. tl;dr: bypasses JavaScript single-threaded event loop
-
TIL LocalForage, a small js library for caching javascript webdev cache api mdn library
An easy to use library to help with web storage. Switches between localStorage/sessionStorage, and also IndexedDB automagically. 178,000 repos can't be wrong.
-
TIL hoisting based on function declarations & function expressions javascript advanced
Function declarations get hoisted on load. So you can use it anywhere. Function expressions do not. Neither are better than another
-
TIL the difference between throttling and debouncing javascript events
Throttling enforces a maximum number of times a function can be called over time. Debouncing enforces that a function not be called again until a certain amount of time has passed without it being called.
-
TIL how Javascript passes data by value, not by reference javascript primitives gif
In JavaScript, primitive types like Number or String are passed by value, not by reference.
-
TIL find() vs filter() javascript arrays
`find()` method return the first value which match from the collection. `filter()` method returns the match value from the array.
-
TIL using code-splitting to improve your First Contentful Paint (FCP) score javascript seo esmodules webpack vue react frameworks
Code splitting is a technique where you send only the necessary modules to the user in the beginning.
-
TIL super keyword in Javascript classes javascript classes mdn codepen
the super keyword is mainly used when we want to access a variable, method, or constructor in the base class from the derived class.
-
TIL using Object.freeze to simulate enums in Javascript javascript datatype objects
Enums are useful to assign names to the integral constants which makes a program easy to read and maintain. The keyword 'enum is used to declare an enumeration.
-
TIL not using the delete keyword for performance issues javascript objects performance
The delete keyword is used to remove a property from an object. Apparently, there is performance issues with `delete` with V8 Javascript Engine.
-
TIL Optimizations with closures javascript closures optimization
To reduce the number of times a variable gets computed, you can use closures. Closures work by storing references to the outer function’s variables. They do not store the actual value.
-
TIL the difference of Closures in Javascript vs PHP php javascript closure
I never knew PHP and Javascript closures were different.
-
TIL the history of the for, forEach, and for...of loops arrays javascript
for loop came first. Then forEach. With new iterables, for...of was adopted.
-
TIL spreading an array into another array javascript arrays
So to merge an array, use the spread operator. '...' <-- that guy
-
TIL Deconstructing Objects javascript codepen objects
Rather than create a big list of parameters in your function, pass the whole object and deconstruct it.
-
TIL about some key elements of NestJS javascript node framework
Controllers, Providers, and Modules OH MY!
-
TIL ES modules and dynamic imports javascript es-modules
Did you know we can also dynamically load modules based on conditionals? The import(path) returns a promise, it fits great with the async/await syntax.
-
TIL a clean way to refactor if/else statements javascript
Not using if-statements gets you closer to the code-as-data concept
-
TIL that you can chain if/else using ternary conditionals javascript
Chaining Ternary conditionals are really neat
-
TIL functions should only do one thing cleancode javascript
The most important rule of programming is - break your code into tiny bite-sized pieces. That makes it easier to compose, test, and add it.
-
TIL iframe sandbox attribute html javascript
The iframe HTML element represents a nested browsing context, embedding another HTML page into the current one. There's also a sandbox mode.
-
TIL Automatic Semicolon Insertion javascript
JavaScript has a 'automatic semicolon insertion' rule. It happens if any of these three scenarios occur.
-
TIL SmooshGate javascript history
It was a a proposal for a JavaScript language feature called `Array.prototype.flatten`.
-
TIL what ES modules are javascript
ES Modules (ESM) is the official, standardize module system to Javascript. What the heck does that mean?
-
TIL a easy way to generate a lot of fake numbers javascript arrays
You need lots of array elements. You got it.
-
TIL why emojis in JS counts as a length of 2 javascript fonts
Characters are written in UTF-16. Emojis are bigger, and require two characters.
-
TIL how to make mobile devices vibrate javascript mobile
The Navigator.vibrate() method pulses the vibration hardware on the device, if such hardware exists.
-
TIL mysterious with keyword in Javascript javascript obsolete
There's a lot of ancient Javascript code that you really shouldn't use, like with
-
TIL when to use local storage vs session storage javascript
We already have the `local storage`, why would we want to use the `session storage`?
-
TIL Eliminating duplicate objects javascript
Using `Set` datatypes can let you do this with no fuss.
-
TIL use JS filter like a pro javascript arrays
To remove falsy items, we use `.filter()` `(Array.prototype.filter())`
-
TIL how to check if the value is an array javascript
If the value is an Array, true is returned; otherwise, false is.
-
TIL How to convert a jQuery plugin to Vanilla JS javascript
To use [Lettering.js](http://letteringjs.com/), which is a reallky neat library, you need to bundle jQuery with it. How about not?
-
TIL array fill references the same object in memory javascript gotchas
When you use `array.fill` to create inner arrays, it's actually just referencing the same space in memory.
-
TIL the XOR operator in Javascript javascript math
The operands are converted to 32-bit integers and expressed by a series of bits (zeroes and ones).
-
TIL How to math the 6 minutes(s) ago without a library javascript dates
Sometimes you need something to print a date to '6 minute(s) ago', but don't want to import monster-size libs.
-
TIL Labels in Javascript javascript
The 'labeled' statement can be used with break or continue statements.
-
TIL prohibit inserting text forms javascript
You may want to prevent the user from pasting text copied from somewhere in the input fields by calling its method preventDefault().
-
TIL ES2021 - plus(+) operator as an alternative parseInt & parseFloat javascript
You can use the + operator in front of any numeric string to parse it as a number.
-
TIL an easy way to populate an data array php javascript
Bonus - I just had to do this in PHP as well, so you get TWO languages for the price of one TIL!
-
TIL Deallocating memory in Javascript javascript
Garbage collection is done automatically in JS. But how does it work?
-
TIL Getting rid of if/else and switch statements javascript
Getting rid of if/else and switch statements
-
TIL Lexical Scoping javascript closure
Lexical scoping describes how a parser resolves variable names when functions are nested.
-
TIL Higher Order functions to reduce loops math loops javascript
Higher Order Functions like Sum, Map, Filter, Reduce
-
TIL Avoiding Off-by-one errors and state using Recusion math loops javascript
Recursion is a function that calls itself.
-
TIL Stateful and stateless math loops javascript
An expression in a programming language can be “stateful” or “stateless”.
-
TIL One-by-one errors math loops javascript codepen
An off-by-one error is when you expect something to be of value N, but in reality it ends up being `N-1` or `N+1`.
-
TIL the problem with using Loops math loops javascript
Loops tend to have some flaws. Instead use Higher Order Functions
-
TIL removing ELSE statements to write clearer code javascript webdev
Programs are meant to be read by humans and only incidentally for computers to execute. Donald Knuth
-
TIL globalThis javascript es2020
`this` doesn't mean the same things depending on environment. Use globalThis
-
TIL Optional Chaining javascript es2020 codepen
The optional chaining `?.` is to see if the value exists
-
TIL Immediately Invoked Function Expression javascript advanced
This is a design pattern where you create a function expression that is immediately executed.
-
TIL Closure as a backpack javascript advanced
The Backpack concept is a mental model to think about how closure saves data behind the scenes.
-
TIL about console.count and console.table debug javascript
Some different ways to show data via your console
-
TIL how the documentation guides Javascript javascript
Essentially, the ECMAScript team makes recommendations. And Javascript engines follow the spec to implement.
-
TIL this one-line script to capitalize the first letter of a word javascript
Other langauges have this. JS has to do it manually
-
TIL about ESNext javascript
ESNext is a name that always indicates the next version of JavaScript. Spoiler.
-
TIL how to scroll to an element in JS javascript
The normal HTML way is with an anchor link. But sometimes, you need to do it with JS.
-
TIL All the Javascript Sandboxes javascript sandbox
You need help? Use a JS sandbox to make their lives easier.
-
TIL Rando.js javascript npm
Node Version Manager might be the reason everything's broken in your life.
-
TIL Node Version Manager javascript npm
Node Version Manager might be the reason everything's broken in your life.
-
TIL Adding a repo as a dependency in package.js javascript npm
If they aren't published as a NPM, you can still do this
-
TIL about RxJS Observables javascript
RxJS is a reactive programming library, using Observables which takes in a stream of data and emits multiple bits of data over time. They get 'subscribed' to, and events fire from that.
See all tags.