Semicolon & Sons
X
About
Contact & Support
Code Diary
Episodes
Blog
Subscribe
Sign in
Semicolon & Sons
About
Screencasts
Code Diary
Blog
Contact & Support
Subscribe
Sign In
Javascript Code Diary Entries
This is part of the Semicolon&Sons
Code Diary
- consisting of lessons learned on the job.
Always consider event bubbling and capturing consequences of your listeners
Anonymous functions do not work with remove event listener
Arrow syntax is not a shorthand
Async must be declared on nearest function even if it is anonymous
Async v defer script tag attributes
Await does not work on lists of promises
Bare javascript requests will not pass CSRF tests
Careful with this
Distinguish between defaults replacing whole object or partially applying to just missing keys
Do not attach listeners for DOMContentLoaded after it already fired
Do not wipe form HTML during submit event
Ensure sending and receiver of custom events is the same obj
General tips
How to debug a node process in chrome
How to get summer time offset
How to mock a promise chain
How to send ENV variables from backend server to javascript in the browser
How to throttle
Html js event attributes need invocation
Input vs change event
Never assume a DOM element is available
Never send un URI encoded parameters to your server from JavaScript
Node programs do not exit if active event listeners
On click does not bind to right click
Pageload vs load events
Precedence issues chaining async code
Prefer defer and DOM content loaded to async
Profiling in chrome
Promise rejected means issue in promise code not issue with promise plumbing
Pros and cons of standard vs object destructuring function signatures
Push pop and replace state
Return values from event handlers
Send image with fetch API
Top level code can be executing multiple times if many entry points
Toplevel variables in vendor docs mean they are really on window
Typescript
Use counters or structured objects to assist debugging asynchronous loops
What is the difference between focus and blur events
You cannot compare dates in javascript
You cannot use await in a constructor