Комментарии:
How javascript object works and do properties(key) stores corresponding values and all the properties will be stored in the consecutive memory location?
Ответить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.
ОтветитьNone if these works btw.
Ответить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.
15? Bro how old are you😂
Ответить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.
Ответитьvery nice
Ответить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'
So, this with() is not recommended and is depreciated?
Ответить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?
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.
what else do you waiting for?
Ответить[…arr].reverse()
[…arr].sort()
arr.map((x, i) => i != 2 ? x : "yay")
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.
Ответитьwhy u didn’t wrote them themselves?
Ответитьyou'd wasted 15 years, take care performance before make any deepcopy.
ОтветитьIt's all the same
ОтветитьUseful, but the inplace methods can be a bit faster because of no memory allocation and less work for a garbage collector.
Ответить'people' looks wierd now
Ответитьlet copy = Array.from(original);
copy[2] = "Eww";
All of these methods are not supported on Firefox jet :/
ОтветитьFirefox is becoming the new IE 😢
Ответитьsorted people ... that's nazi code
ОтветитьThank you so much for sharing with us.
ОтветитьYou didn't need to wait pfff. So hard to make your own functional interfaces that fits your requirements?
ОтветитьWhat about using a class Collection<type> instead ?
ОтветитьKyle, was this a very elaborate way to let us know you had a baby with Sally and his name is John?
ОтветитьThat's pretty amazing considering the fact that you're a 12 year old making videos in his grammy's craft room.
ОтветитьWhy you no semicolon
Ответить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)
ОтветитьReact-driven JS changes... This world becomes crazy...
ОтветитьI waited 50 yrs 😤😤😤😤
ОтветитьJesus, what a god forsaken programming language...
ОтветитьWhy is there no method to copy the array?
ОтветитьIsn't toSpliced() the same as slice()?
Ответить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.
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.
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)
ОтветитьAnd Smalltalk had these and more since 70's
Ответить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)}`
ОтветитьRemember that the spread operator "..." only performs a shallow copy on non-nested data.
ОтветитьBecause thery are pure method,not change raw data
Ответить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 ?
ОтветитьYou waited 15 years for something that wouldn't even take an afternoon to code?
ОтветитьFor God's sake, just use Immer 😂 why are people still manually performing immutable updates on state objects?
Ответить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.
ОтветитьReversing array before sorting?
My eyes xD
Gr8 and most comprehensive video on data normalisation
Ответить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
Ответить