I Waited 15 Years For These New Array Methods

I Waited 15 Years For These New Array Methods

Web Dev Simplified

11 месяцев назад

221,147 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@srinuvanam4043
@srinuvanam4043 - 22.12.2023 12:11

How javascript object works and do properties(key) stores corresponding values and all the properties will be stored in the consecutive memory location?

Ответить
@magnanova
@magnanova - 21.11.2023 00:36

const newPeople = people.slice().sort(); is the old way of doing people.toSorted(); For the vast majority of use cases this was just fine. toSorted() is maybe 5% faster.

Ответить
@govindpvenu
@govindpvenu - 11.11.2023 06:08

None if these works btw.

Ответить
@harmez7
@harmez7 - 05.11.2023 02:47

Kyle do you really have to lie? 15 years ago you were NOT a programmer and you dang know it!
Lie corrupts man's soul dont flipping do it please.

Ответить
@ricksanchez-c-137
@ricksanchez-c-137 - 21.09.2023 04:44

15? Bro how old are you😂

Ответить
@cherubin7th
@cherubin7th - 14.09.2023 20:45

Great, even more you need to remember if you want to be able to read JavaScript. Just so that 5 people can type one line less per project.

Ответить
@belvederepapi7495
@belvederepapi7495 - 01.08.2023 03:03

very nice

Ответить
@user-qv4tx6yd3y
@user-qv4tx6yd3y - 30.07.2023 18:13

const copyPeople = [...People].with(2, "new");
^

TypeError: [(...People)].with is not a function
at Object.<anonymous> (D:\jsPract30072023\main.js:2:36)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

why im facing this issue'

Ответить
@williamt.roberts4771
@williamt.roberts4771 - 25.07.2023 16:47

So, this with() is not recommended and is depreciated?

Ответить
@talkohavy
@talkohavy - 21.07.2023 02:21

Hey, I have a serious question.

How did you get notified about these methods coming out and being released?
I also want to be like you, in the sense that i want to be up-to-date with new stuff coming out or getting updated.
Is there a JavaScript newsletter that you're subscribed to?
How did YOU first learn of these 4 new methods?

Ответить
@KAZVorpal
@KAZVorpal - 03.07.2023 20:12

Hold on, if the goal of your peopleCopy example is to avoid mutation
a-la Purely Functional Programming,
then surely it's problematic.
You make a new copy, then mutate that copy.
While this may be nit-picking, ideally one never mutates data at all.
So you need to make the new array WITH THE CHANGE ALREADY EXISTING in it.
array.with() does this correctly, with no mutation at all.

Ответить
@mralexander3289
@mralexander3289 - 22.06.2023 14:51

what else do you waiting for?

Ответить
@nitsanbh
@nitsanbh - 20.06.2023 18:18

[…arr].reverse()
[…arr].sort()
arr.map((x, i) => i != 2 ? x : "yay")

Ответить
@-Jakob-
@-Jakob- - 18.06.2023 11:35

I understand the purpose but to me it's just weird unintuitive syntax and it's going into the wrong direction and doesn't make it better. Using the spread operator before doing anything that mutates is just fine for me, now and in future.

Ответить
@mr.javeline4526
@mr.javeline4526 - 17.06.2023 12:20

why u didn’t wrote them themselves?

Ответить
@DatNickNganGonVaDeNho
@DatNickNganGonVaDeNho - 16.06.2023 19:18

you'd wasted 15 years, take care performance before make any deepcopy.

Ответить
@romanbrandt7986
@romanbrandt7986 - 14.06.2023 09:52

It's all the same

Ответить
@filyus_is_here
@filyus_is_here - 13.06.2023 23:34

Useful, but the inplace methods can be a bit faster because of no memory allocation and less work for a garbage collector.

Ответить
@demarioward4145
@demarioward4145 - 13.06.2023 07:52

'people' looks wierd now

Ответить
@vukkulvar9769
@vukkulvar9769 - 12.06.2023 15:13

let copy = Array.from(original);
copy[2] = "Eww";

Ответить
@lazarvukosavljevic9575
@lazarvukosavljevic9575 - 12.06.2023 12:28

All of these methods are not supported on Firefox jet :/

Ответить
@truvc
@truvc - 10.06.2023 20:07

Firefox is becoming the new IE 😢

Ответить
@KaribaKariba
@KaribaKariba - 10.06.2023 17:04

sorted people ... that's nazi code

Ответить
@shahfaisal3923
@shahfaisal3923 - 10.06.2023 12:07

Thank you so much for sharing with us.

Ответить
@sajgon338
@sajgon338 - 09.06.2023 13:11

You didn't need to wait pfff. So hard to make your own functional interfaces that fits your requirements?

Ответить
@flamme8587
@flamme8587 - 09.06.2023 13:04

What about using a class Collection<type> instead ?

Ответить
@fantasticfreddie
@fantasticfreddie - 09.06.2023 12:39

Kyle, was this a very elaborate way to let us know you had a baby with Sally and his name is John?

Ответить
@waytospergtherebro
@waytospergtherebro - 09.06.2023 08:49

That's pretty amazing considering the fact that you're a 12 year old making videos in his grammy's craft room.

Ответить
@illegalsmirf
@illegalsmirf - 08.06.2023 15:04

Why you no semicolon

Ответить
@foxcirc
@foxcirc - 08.06.2023 12:44

My problem with this is that it makes it really easy to create a lot of copies, which is no different then spread. Doing functional style programming without mutation in a language like Javascript where the compiler is not designed optimize these patterns is problematic and this makes it really easy to create slow code. I think generally you should prefer mutability (in JS)

Ответить
@cynep6y6Jluk
@cynep6y6Jluk - 08.06.2023 10:44

React-driven JS changes... This world becomes crazy...

Ответить
@nextfangtechlead6239
@nextfangtechlead6239 - 08.06.2023 01:35

I waited 50 yrs 😤😤😤😤

Ответить
@neagudan
@neagudan - 07.06.2023 22:32

Jesus, what a god forsaken programming language...

Ответить
@myronkipa2530
@myronkipa2530 - 07.06.2023 08:49

Why is there no method to copy the array?

Ответить
@elozinoovedhe
@elozinoovedhe - 07.06.2023 00:35

Isn't toSpliced() the same as slice()?

Ответить
@bilalarain4632
@bilalarain4632 - 06.06.2023 21:57

I think in this erra of unlimited memory and storage availability we should less worry about array mutability.
rather a
simple
[...orignalArray].reverse would do the job
and the best part for managing memory on your own is to
assign [...originalArray] to a variable and then undefined or despose it later.

Ответить
@jacqueskloster4085
@jacqueskloster4085 - 06.06.2023 21:49

My daily observation is that array methods instead of loops are often a source for cascaded full table scans of unexperienced developers...

To be honest, I try to avoid then whenever possible. Yet, there are absolutely valid use cases for them. But a concatenated find filter map some isnt one.

Ответить
@sonictailsandsally
@sonictailsandsally - 06.06.2023 19:06

With respect to time complexity, iterating through an array twice performing one action is no different to iterating through an array once performing two actions. The time complexities are the same: O(n)

Ответить
@SebastianSastre
@SebastianSastre - 06.06.2023 18:50

And Smalltalk had these and more since 70's

Ответить
@ChristianHeilmann
@ChristianHeilmann - 06.06.2023 16:47

Just a hot tip: if you want to speed up your console.log() explanations, simply wrap what you want to log in curly braces. console.log({sorted}) will result in `{sorted: Array(3)}`

Ответить
@latedriver9019
@latedriver9019 - 06.06.2023 07:32

Remember that the spread operator "..." only performs a shallow copy on non-nested data.

Ответить
@quanluo190
@quanluo190 - 06.06.2023 05:25

Because thery are pure method,not change raw data

Ответить
@user-xm7yq1re2b
@user-xm7yq1re2b - 06.06.2023 03:45

can you do a step by step tutorial building a ptc site with database ,user registration , ad serving page,admin panel and show how to connect everything across ?

Ответить
@N0ES
@N0ES - 06.06.2023 02:10

You waited 15 years for something that wouldn't even take an afternoon to code?

Ответить
@alexjeffrey3981
@alexjeffrey3981 - 06.06.2023 01:44

For God's sake, just use Immer 😂 why are people still manually performing immutable updates on state objects?

Ответить
@adimetrius
@adimetrius - 06.06.2023 00:32

JS was overstuffed as it was, now more stuff is being added... Also, shameful performance of browsers - it's on methods like that. They let coders code things 'easily', in 'one-liners', without having the slightest idea of costs and performance implications.

Ответить
@JulasssPL
@JulasssPL - 05.06.2023 23:44

Reversing array before sorting?
My eyes xD

Ответить
@expertreviews1112
@expertreviews1112 - 05.06.2023 23:30

Gr8 and most comprehensive video on data normalisation

Ответить
@stewart6395
@stewart6395 - 05.06.2023 19:45

I had to update Chrome to the latest version to make these methods work. The time hasn't come yet to use these features, because people rarely update their browsers and there's a high risk of breaking your app for them. So it could be a year or so before we can use all this new stuff in production

Ответить