khalidabuhakmeh, I’m about to make many #JavaScript developers feel very old. Apologies in advance.
cspray, One time I found some #JavaScript in an app that was constructing a full blown
SELECT
statement in SQL, sending it to the server, and then blindly executed on that server.It is still the most glorious, beautiful code I've ever seen.
ramsey, @cspray This sounds like a Good Thing™.
simon, @cspray I did that once for a project as a joke (against a read-only SQL API) and found it was actually a really neat way to rapidly iterate on my project!
You can view source on https://sf-trees.com to see a demo of the pattern I built
baumannzone, Spanish #JavaScript WTF
keithjgrant, @baumannzone This has to do with how floating point numbers are stored (essentially, they’re fractions, not decimals). This occurs in most programming languages, not just JS. Look up “floating point rounding error”
keithjgrant, @baumannzone Here's python doing the exact same thing
nucliweb, Comprehensive guide to JavaScript performance analysis using Chrome DevTools
https://blog.jiayihu.net/comprenhensive-guide-chrome-performance/
ricmac, This was the top performing post on @TheNewStack last week, so it seems there is a tremendous amount of interest in a post-React future among web developers. Maybe my Gmail analogy wasn’t far off after all ;) https://thenewstack.io/from-react-to-html-first-microsoft-edge-debuts-webui-2-0/ #WebDevelopment #javascript #htmlfirst https://mastodon.social/@ricmac/112531029962000384
ecmascript_news, fetch-in-chunks: fetching large files in chunks, with parallel downloads, progress tracking and request abortion
@tomayac
https://github.com/tomayac/fetch-in-chunks/
jesus,
joelanman, given
delete
is a keyword in JavaScript, what word do you use for a function that deletes in your own code?del
,destroy
, other?
joelanman, @yatil ha ha I like it
joelanman, @jscholes I'm writing it in a file that is then imported, so something like
function delete (id) { // do deletion } module.exports = { create, delete, update }
then elsewhere
const myThing = require('myThing') myThing.delete(id)
mikestreety,
mikestreety, Solved by moving everything into Vue and not using the data attributes elsewhere
ricmac, With frontend development, is it better to start simple and build on top of standard HTML, CSS and JavaScript? Or do you need a swiss army knife framework, like Next.js or Angular? I looked at recent Vue developments and found a lot to like about its "progressive framework" approach. https://thenewstack.io/want-out-of-react-complexity-try-vues-progressive-framework/ #vue #vuejs #javascript #frontend
librenews, @ricmac FYI, there is a link in the article in the Progressive Frameworks section to vue.js - think it's supposed to be vuejs.org
ricmac, @librenews good catch, thanks! I have updated the link.
32bitkid, Spent a bit of time early this morning to knock out the most basic vector editing features in my SCI0 pic editor. The SCI0 pic byte-code is very terse; it doesn't even have closed polygons, just lines that happen to touch each other when rendered to the frame-buffer.
I'm sure this whole UI layer will need a refactor soon, but its definitely another step in a "useful" direction. Just a few core features left before a "beta" is viable.
javedAB, #people want fast-loading pages
one way to achieve this is by loading only the necessary #javascript initially
load the rest on hover or button click for a smoother experience
aeveltstra, @javedAB Other ways to achieve it include removing Javascript altogether and replacing it by server-side scripting, as well as serving most if not all of your sources over a fast CDN.
javedAB, @aeveltstra server side rending is a valid approach. i started with @astro and @solid_js . however, from what i guess, server side rendering is more cost intensive than static html
fast cdn can be combined with lazy loading #js
m0rpk, Looking for help from #JavaScript and / or Apple Mac people.
I have before me an old MacBook Pro running #MacOS 10.13.6. It can't be upgraded because of hardware constraints.
No browser on this device will render the #emfcamp schedule here: https://www.emfcamp.org/schedule/2024
I see JS console errors like "TypeError: Object.groupBy is not a function"
I've tried #Chrome, #Firefox, and #Safari.
Is it possible a script on that page relies on an OS feature this machine lacks?
penginn, 好きなだけおちんちん祭りを続けることができてしまったのです。
目に見えない文字を悪用してサイトを好き放題荒らされた話 [#JavaScript - Qiita ]
https://qiita.com/laineus/items/2d168a57fdbf7cd7c9c3
siblingpastry, Here's a very-niche but then-very-useful #javascript trick I realized today -- you can create empty text-nodes to use as node references, for things like DOM insertion, range boundaries, or whatever.
I needed this to set the end of a range immediately before an element's closing tag, when references to existing child nodes might be invalidated by race conditions.
You don't even need to persist the references for removal, since a single call to context.normalize() cleans them all away.
ollicle, @siblingpastry I took the time to look up normalize and answered my own question.
Comments might be a little easier to spot in dev tools, but certainly more fuss to tidy.
siblingpastry, @ollicle Oh you were asking about dealing with sibling text nodes? Yeah, that :-) Normalizing isn't something you tend to need very often, but it's uniquely useful when you do.
That's a good point about spotting in dev tools, I guess it would depend on what you needed. If the nodes need to be around for a while, it would be more useful to be able to inspect them. My use-case is very transient, they're added and gone again in the space of a synchronous function call.
rauschma, This is legal syntax:
{3:3}Why? You can use numbers as keys in object literals. That can be useful for destructuring [1]:
> const {0:a, 2:c} = ['zero', 'one', 'two'];
> a
'zero'
> c
'two'However, this is not legal syntax:
> const x = {3};
SyntaxError: Unexpected numberWhy? This is called a property value shorthand [2] and only works with names of variables.
[1] https://exploringjs.com/impatient-js/ch_destructuring.html
[2] https://exploringjs.com/impatient-js/ch_objects.html#object-literals-property-value-shorthands
rauschma, You can also destructure with computed property keys (*):
const key = 'a';
const {[key]: x} = {a:1, b:2};
assert.equal(x, 1);(*) https://exploringjs.com/impatient-js/ch_objects.html#object-literals-computed-keys
jbzfn, ⌛ The End of an Era: Microsoft Phases Out VBScript for JavaScript and PowerShell | @thehackernews
"Both NTLM and VBScript are known to be abused by threat actors to conduct malicious activities, prompting Redmond to remove features in an attempt to minimize the attack surface"
https://thehackernews.com/2024/05/the-end-of-era-microsoft-phases-out.html
twilliability, Question #Javascript folks! If I use destructuring assignment as below, is an actual array allocated for the function's return value, or does the runtime recognize this and optimize it away?
Asking for a friend living in a tight loop.
const [a, b] = foo();
quesebifurcan, @twilliability I'm not sure if it matters in practice, but it looks like v8 has been optimizing array destructuring since 2018 https://v8.dev/blog/v8-release-68#array-destructuring-improvements
twilliability, @quesebifurcan This is exactly what I was looking for, thanks! If V8 has had it for 6 years, then I assume it's the same in FF too.
eikun_0903, Japanese dailycoding - 20240524 / graphic
#p5js #javascript #Processing #generativeart #creativecoding #dailycoding
code : https://openprocessing.org/sketch/2281794
nurkiewicz, "Top 5 Cutting-Edge #JavaScript Techniques". TL;DR:
- Monads (Asynchronous Operations)
- Declarative Programming
- Server-Side Caching for Improved Node.js Performance
- Immutability
- Pattern Matching
https://thenewstack.io/top-5-cutting-edge-javascript-techniques/
awlex, @nurkiewicz They should make programming languages where those techniques are enforced by default
markstos, Is EventEmitter the GOTO of #javascript ?
rauschma, Upcoming #JavaScript iterator methods:
// Without iterator methods:
const arr = Array.from(myMap.keys())
.filter(k => isPublic(k));// With iterator methods:
const arr = myMap.keys()
.filter(k => isPublic(k))
.toArray();(I prefer not to do .filter(isPublic) because isPublic() may gain more parameters in the future.)
voxpelli, @rauschma I have been looking forward to these!
I assume they don’t work with AsyncIterators?
javajuggler, Could someone help me solve this problem with javascript? Palindrome Check: Write a function to check if a string is a palindrome. he's number 3 on this list - https://chat-to.dev/post?id=141
HuntressHimbo, (edited ) Hi, I don’t think giving you the answer directly will help you learn it, but I can give you some general tips for this.
First here is the MDN documentation for the string type: developer.mozilla.org/en-US/docs/Web/…/String
On the left hand side you should see a column with methods the string type contains. You can use several of these to accomplish a palindrome check. String.slice(), String.charAt(), String.at(), String.match(), and String.substring() are all methods that you can use to write your check.
In addition to those, I would recommend looking at String.toLowerCase()/String.toUpperCase() to avoid issues with capitalization, and String.trim() to avoid trailing or leading whitespace.
Also you will need a variable to store your result, my general recommendation is to start this variable as true and set it to false when you detect any inconsistency, and probably one to store the index you are currently checking. Last little tip is that many String methods accept negative indices to count from the end rather than from the start. Good luck!
One more giant tip because I don’t know what your experience with JavaScript is, but pay attention when comparing that you don’t use == when you should use === and vice versa. The difference is that == will try to coerce the values to the same type before comparison, which can lead to.unintuitive behavior
javajuggler, @HuntressHimbo
thanks for the tip
scy, Theo on const vs let in #JavaScript:
https://youtu.be/dqmtzHB2zTM (32 min).
It's a long video, and he's basically only reacting to and commenting on Let me be https://www.epicweb.dev/talks/let-me-be (12 min) by Ryan Florence.
Theo's main point is that const doesn't mean "this value will never change" (since objects and arrays can obviously still be mutated), but that let means "pay attention, this value will be reassigned further down", and I totally agree.
stackdpodcast, #72 is out! @kito99 and @dhinojosa welcome @edwinderks, a @JavaChampions member, #MicroProfile and #JakartaEE contributor, and Principal Consultant at Team Rockstars IT. They discuss #JakartaData, the Jakarta EE Starter, #JMS, #Kafka, #SSR, #Angular, #CustomElements, #Kotlin, #JDK 22, Google #Genie and energy hungry #LLMs. #ai https://www.pubhouse.net/2024/05/stackd-72-travel-llms-coffee-avocados-and-almonds.html