4 ms·
More specifically, how JavaScript can do a lot in browser by interacting through the DOM API. The modernization of the DOM API in the last 5 years has done a l
by dhritzkiv 6y ago
More specifically, how JavaScript can do a lot in browser by interacting through the DOM API.
The modernization of the DOM API in the last 5 years has done a lot to remove the need for jQuery et al, and has made building the View part of JavaScript apps much more frictionless.
- ed25519FUUU 6y agoWhere can we learn about this “modern JS“? I feel like in some ways I’m learning the old ways, similar to old c++.
- bartread 6y agoThe parent isn't talking about JS: they're talking about the DOM APIs. The best resource I've found for learning about these is MDN: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model https://developer.mozilla.org/en-US/docs/Web/API/Document_Ob.... I've found this to be an incredibly helpful reference when I need to do something without using a library.
- zamadatix 6y agoFollowing the tc39 proposals on GitHub is a great way to keep up with features just being added. "What's new in ES2020" type blog posts should catch you up between then and the bleeding edge. MDN for actually getting the technical details on things as you try to implement the features you read about (will also xover browser specific APIs). caniuse to see if they are actually ready to be used.
- monoideism 6y agoIt's both modern Web APIs as well as ES6 JavaScript, both of which make working in VanillaJS quite pleasant. If you don't need to support older browsers, you don't even need to use any packaging software (although if you're building a serious app, it's still wise to do so). You can import ES6 modules in vanilla JS, and a modern browser will do the loading for you. Great for quick starts.
- dmitriid 6y agoYou still end up re-implementing half of jQuery. Because element creation is just as much passion as it was in 1999. Because useful functions are limited or stunted compared to jQuery counterparts (querySelectorAll returns a weird object instead of an array and throws exceptions if you as as much as as look at it funny, etc.).
- clairity 6y agoha, i just went through this today, querySelectorAll returns a NodeList, which is static rather than live, requiring you to iterate through the list rather than acting on the elements directly. but it's nice that jquery (as convenient as it is) is no longer a must-have library for dom manipulation.
- runarberg 6y agoEither iterate through the `NodeList` with a `for ... of` loop or a `.forEach` method, or convert it to an array using `Array.from()` or `[...nodeList]`. `NodeList` can be a live list (not `querySelectorAll` though) which has some benefits over arrays. `NodeList` also implements `Symbol.iterator` so you can use your favorite iterator library if you need to map, filter or reduce it. And with the future pipeline operator, you’ll really don’t see a different between a standard array and a fancy structure like `NodeList`.
- dmitriid 6y agoYou just spent three paragraphs describing how NodeList is different, including a reference to a non-existent operator. Nice.
- hombre_fatal 6y agoWell, you called it a "weird object" that throws errors if you "look at it funny." They tried to demystify it for you in just three sentences. That jQuery lets you willfully cling to the corpse of familiarity instead of spending 30 seconds looking up what NodeList was years ago says more about you than anything about jQuery. And with your end-cap comment about the pipeline operator that they were already, helpfully, pointing out was going to be introduced in the future, you just sound like sour grapes. What gives? Kind of a weird attitude to bring to a forum of craftspeople.