JavaScript

khalidabuhakmeh,
@khalidabuhakmeh@mastodon.social avatar

I’m about to make many developers feel very old. Apologies in advance.

https://mootools.net/

nemeciii, (edited )
@nemeciii@mastodon.social avatar

@khalidabuhakmeh I was more into http://prototypejs.org/

When I started pushing web in 2002 we had none of these, just unstable JS and some poor CSS.

cspray,
@cspray@phpc.social avatar

One time I found some 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,
@ramsey@phpc.social avatar

@cspray This sounds like a Good Thing™.

simon,
@simon@simonwillison.net avatar

@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
@baumannzone@techhub.social avatar
keithjgrant,
@keithjgrant@front-end.social avatar

@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,
@keithjgrant@front-end.social avatar

@baumannzone Here's python doing the exact same thing

nucliweb,
@nucliweb@webperf.social avatar

Comprehensive guide to JavaScript performance analysis using Chrome DevTools

https://blog.jiayihu.net/comprenhensive-guide-chrome-performance/

ricmac,
@ricmac@mastodon.social avatar

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/ https://mastodon.social/@ricmac/112531029962000384

ecmascript_news,
@ecmascript_news@mastodon.online avatar

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,
@jesus@mastodon.gamedev.place avatar
joelanman,
@joelanman@hachyderm.io avatar

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,
@joelanman@hachyderm.io avatar

@yatil ha ha I like it

joelanman,
@joelanman@hachyderm.io avatar

@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@hachyderm.io avatar

Diving back into a project that used Vue and it seems to be throwing an error when I add a data- attribute to a HTML element. It's a static string which I use for something else.

Is there a way I can tell Vue to just ignore it?

#Vue #vuejs

mikestreety,
@mikestreety@hachyderm.io avatar

Solved by moving everything into Vue and not using the data attributes elsewhere

ricmac,
@ricmac@mastodon.social avatar

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,
@librenews@mastodon.social avatar

@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,
@ricmac@mastodon.social avatar

@librenews good catch, thanks! I have updated the link.

32bitkid,
@32bitkid@mstdn.social avatar

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.

#JavaScript #Vue #RetroComputing #SierraOnLine

video/mp4

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

#webdesign #ux #coding #frontend #webdevelopment

aeveltstra,
@aeveltstra@mastodon.social avatar

@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,
@m0rpk@mastodon.radio avatar

Looking for help from and / or Apple Mac people.

I have before me an old MacBook Pro running 10.13.6. It can't be upgraded because of hardware constraints.

No browser on this device will render the schedule here: https://www.emfcamp.org/schedule/2024

I see JS console errors like "TypeError: Object.groupBy is not a function"

I've tried , , and .

Is it possible a script on that page relies on an OS feature this machine lacks?

penginn,

好きなだけおちんちん祭りを続けることができてしまったのです。

目に見えない文字を悪用してサイトを好き放題荒らされた話 [ - Qiita ]
https://qiita.com/laineus/items/2d168a57fdbf7cd7c9c3

siblingpastry,
@siblingpastry@mastodon.world avatar

Here's a very-niche but then-very-useful 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,
@ollicle@mastodon.social avatar

@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,
@siblingpastry@mastodon.world avatar

@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,
@rauschma@fosstodon.org avatar

#JavaScript:

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 number

Why? 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,
@rauschma@fosstodon.org avatar

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,
@jbzfn@mastodon.social avatar

⌛ 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,
@twilliability@genart.social avatar

Question 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,
@quesebifurcan@mastodon.social avatar

@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,
@twilliability@genart.social avatar

@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
@eikun_0903@fedibird.com avatar
nurkiewicz,
@nurkiewicz@fosstodon.org avatar

"Top 5 Cutting-Edge #JavaScript Techniques". TL;DR:

  1. Monads (Asynchronous Operations)
  2. Declarative Programming
  3. Server-Side Caching for Improved Node.js Performance
  4. Immutability
  5. 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,
@markstos@urbanists.social avatar

Is EventEmitter the GOTO of #javascript ?

davesh,
@davesh@hachyderm.io avatar

@markstos yes and we like it

rauschma,
@rauschma@fosstodon.org avatar

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.)

https://2ality.com/2022/12/iterator-helpers.html

voxpelli,
@voxpelli@mastodon.social avatar

@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,
@scy@chaos.social avatar

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.

#const #let

sebsch,
@sebsch@chaos.social avatar

@scy is there anything in that language that is not partially broken?

stackdpodcast,
@stackdpodcast@mastodon.social avatar

is out! @kito99 and @dhinojosa welcome @edwinderks, a @JavaChampions member, and contributor, and Principal Consultant at Team Rockstars IT. They discuss , the Jakarta EE Starter, , , , , , , 22, Google and energy hungry . https://www.pubhouse.net/2024/05/stackd-72-travel-llms-coffee-avocados-and-almonds.html

  • All
  • Subscribed
  • Moderated
  • Favorites
  • javascript
  • DreamBathrooms
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • mdbf
  • GTA5RPClips
  • JUstTest
  • tacticalgear
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • ethstaker
  • anitta
  • provamag3
  • Leos
  • cisconetworking
  • megavids
  • lostlight
  • All magazines