@teodorsandu@mastodon.online
@teodorsandu@mastodon.online avatar

teodorsandu

@teodorsandu@mastodon.online

This profile is from a federated server and may be incomplete. Browse more on the original instance.

teodorsandu, to Funny
@teodorsandu@mastodon.online avatar
teodorsandu, to Funny
@teodorsandu@mastodon.online avatar
teodorsandu, to legal
@teodorsandu@mastodon.online avatar
teodorsandu, to IT
@teodorsandu@mastodon.online avatar
teodorsandu, to Meme
@teodorsandu@mastodon.online avatar
arda, to programming
@arda@micro.arda.pw avatar

Brain gymnastics: Which approach would work faster? And why?

#js #javascript #poll #object #programming

teodorsandu,
@teodorsandu@mastodon.online avatar

@arda hint: you could actually Add a Poll, via the button next to the Attachments button which you used to upload the image.

teodorsandu,
@teodorsandu@mastodon.online avatar

@arda oh, and my answer would have been Approach 3: ['key1', 'key2'].every(itm => typeof(obj[itm]) !== 'undefined');

After running the benchmark i saw i was very close actually, 2nd fastest, almost as fast as the 'in' operator https://measurethat.net/Benchmarks/Show/977/0/undefined-vs-typeof-vs-in-vs-hasownproperty

So the fastest way is Approach 4: ['key1', 'key2'].every(itm => itm in obj);

teodorsandu,
@teodorsandu@mastodon.online avatar

@arda well, we learn new things every day :) i never noticed that one button gets hidden once you use the other until you pointed it out - thanks! and sorry for the unnecessary suggestion

teodorsandu,
@teodorsandu@mastodon.online avatar

@arda hasOwnProperty is right there with typeof, 'in' and double negation, its complexity must be O(1) as well. So yes, it definitely wins over anything that spends time creating and iterating over arrays.

teodorsandu,
@teodorsandu@mastodon.online avatar

@arda not exactly, i just added an equivalent, simplified version to the existing test i linked earlier. There's a Fork button you can use to add you own test cases.

fell, to javascript
@fell@ma.fellr.net avatar

Let's just delete #JavaScript and write websites in #C again.

teodorsandu,
@teodorsandu@mastodon.online avatar

@fell Done. #wasm ๐Ÿ˜…

teodorsandu, to tech
@teodorsandu@mastodon.online avatar
teodorsandu, to UI
@teodorsandu@mastodon.online avatar
teodorsandu,
@teodorsandu@mastodon.online avatar

@djoerd sure, which vegetarian would you like us to cook for you?

...jokes aside, there doesn't seem to be any obvious choice though https://thenounproject.com/search/icons/?q=vegan+menu

teodorsandu, to random
@teodorsandu@mastodon.online avatar

Seems legit :)

itnewsbot, to javascript
@itnewsbot@schleuss.online avatar

Recharts: Intro to JavaScript charting - The JavaScript ecosystem includes many charting libraries, but itโ€™s tough to create a ... - https://www.infoworld.com/article/3707388/recharts-intro-to-javascript-charting.html#tk.rss_all #developmentlibrariesandframeworks #softwaredevelopment #javascript #react

teodorsandu,
@teodorsandu@mastodon.online avatar

@itnewsbot you have more space on #mastodon so you can be a bit more specific. #Clickbait toots are not cool. Muted.

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