16.6: Array Functions: map() and fill() - Topics of JavaScript/ES6
HTML-код
- Опубликовано: 1 окт 2024
- In this video, I discuss two array functions in JavaScript: map() and fill().
🎥 Next Video: • 16.7: Array Functions:...
🔗 MDN's Array Documentation: developer.mozi...
🎥 Prototypes in JavaScript: • 9.19: Prototypes in Ja...
🚂 The Coding Train website: thecodingtrain....
💖 Support this channel on Patreon: / codingtrain
🛒 To buy Coding Train merchandise: www.designbyhu...
📚 Book recommendations: www.amazon.com...
💻 github.com/Cod...
🎥 For an Introduction to Programming: • Start learning here!
🎥 For More Coding Challenges: • Coding Challenges
🔗 p5js.org/
🔗 processing.org
📄 Code of Conduct: github.com/Cod...
Most enjoyable JS tutorials ever, I don't even need coffee...
Are you saying you don't need... Java?
@@SakosTechSpot nah. just java.....script
I did not think for once that I could enjoy watching JS tutorials!
Dude, you get too excited, I love it!!
He almost died at some point there, I did not know it was so dangerous to make a youtube video
What is The problem with that ??? I think Its relly help us to stick to the video and entertant us while learning . what You say
dude
did he just say "Welcome back bby" ? xD lmao
benjamin ghys I think he said "maybe"... dunno 🤷🏼♂️
LMAO YES
rofl that's what I heard
Every time I watch a coding train video I'm happy.
(plus, I can't help myself thinking "This guy is the cutest thing on Earth" lol).
oh my god same. he is so adorable
This guy is the type of guy that can make everyone in the room feel happy even if you're sad that day
I really appreciate the work you put into creating these videos. You are my to go guy if when I can't understand a concept. THANK YOU!!
You have thought me so much. Thank you! Ur my favourite youtuber.
He is the greatest programmer in history of mankind
Flash Drive surely the most energetic one though !!
I love how weird this guy is. 10:32 i died XD Lol
Man I wish I had a teacher like you in the past, like your teaching style, the way you make it look fun, and also have a good time and laughs watching your videos! Thanks!
Trying to learn about arrays and this guy has me laughing my ass off! Thanks for the great content!
This guy is awesome
Maaaaan! I found this and I loved this tutorial jajajajaja The part of the glasses you made me laugh 😂 I love your energy and the way you explain
I m literally laughing during watching this video
awesome Tutorial!!!!
You are truly a great instructor, I love how you do things, you got me from the first video man.
Thanks for that! Very well explained! I saw the entire video, but just for recaps:
03:17 - map()
08:32 - fill()
thank you!
I can´t believe this content is free. I would hug you very strongly and then thank you for it.
stop calling me baby im starting to develop feelings for you
OMG YOU MAKE ME EXCITED TO CODE! Thanks so much. I'm so glad I found you!
By default my localhost files open in Edge. Couldn't get the results, and began to question whether I'm reading the code in this tutorial correctly. Suddenly noticed he's using Chrome. Guess what happened? The code worked. What lesson did we learn today? Screw Edge for all its purposes.
I genuinely have fun watching him while learning so much!
nothing like coding train in the morning :^
what about
vals=Array.from({length:100},Math.random)
:D
8:11 😂😂😂😂😂😂😂😂❤❤❤❤
Love From India ❤️
To create an array with 100 random elements you can also do : Array.from({length: 100}, () => Math.random());
Glass are going expensive. There's gonna be more ads....5 seconds later... ad in 5,4,3,2,1.
watching his video is much more better than reading my textbook
What is The difference Between map () and filter() method Guys ??? Both The Higher Order function will do the same job I think !
can anyOne explain me ???
Map() =>will Take The Function as aarnument and Return new array based On some condtion;Inside that function. and
filter()=>will also Take the function as a argument and Return New array based on some condition inside that function;
so How do we decide That when to use what ?????
and awsome Video sir Love from India.
I'm replacing coffee with watching Coding Train every few hours.
How are we not declaring vals at the very end? vals = Array(100)..... is it because we're creating a new array? I'm Java trained and just getting back into Javascript.
you are a legend, man
At the rate code is being shortened, by 2020 you’ll type x and your code will intuitively return the meaning of life.
Btw, the map function is super handy when manipulating arrays for Google Charts.
x = 42;
@@dansxmodsdditj me may
Lots of junk and mistakes that are incredibly distracting and confusing. The constant excessive hands gesticulation also does not contribute to the ideal perception. The author's unfounded amusement is only annoying. All that is missing is the jester's red nose. Of the originally planned four functions, managed to explain only one... Cool!
Stylish, noisy, but it's not about learning javascript. Sorry.
Some methods create new array, other change the existing array.
For example sort() changes existing array.
Great channel! Thanks
how is this guy so cool?
More people need to see this guy, I wish your channel grows much bigger and everyone can benefit from your teaching. Thanks a lot.
My english words isn't full, but i understand lesson, because of teacher's emotions )))) sorry for english
Some people enjoy when others fail... they could have moments of happiness watching this video ;-) Even it was success to make mistakes and find solution some people would enjoy that process as their ilussion to be generally better...
If only I had like 50% of your enthusiasm when talking.....
I don't know how I came here. BUT THANKS GOD! You are amazing! Even your pronuntiaton makes easy to understand to non english speakers. Thanks a lot!
Jesus christ my brain doesn't like this. I much prefer just writing it like a normal person tbh.
hi, cant find the video but in one of your vids a made a statement about the volume of your outro... please dismiss that, i discovered it was actually an issue with my sound equalizer haha. i fixed the issue now the volumes are synced well. thank you for your help with learning more about programming with javascript, it is a huge help
Thanks man, but crud you dither, get to the point already.....fluff stops at about 3:20
You made the fill and array the most confusing thing ever... It was unnecessary
Don't get to much excited while teaching . If u would get more excited u may break your whole setup
You are Awesome sir Its an honor to be your student. It was my first video lecture with you, sir.
its normall to drop your glasses like that, your brain works way more faster than normal at exact at that time so you lose motor function control.
Each and every corner you are explained very clearly and understandable... thank you keep doing
Love how you get excited about stuff no one really wants to talk about just for the sake of talking about it!
10:33 So...fill...isn't...a...higher order...function??
Normally don't like your style as you are a little to energetic but you this was perfect, thank you!
I fucking love the energy and passion of these tutorials
lol,Try not to smoke weed before recording lectures next time.
Thanks for doing these array tutorials, they really help.
btw glasses being expensive, did you know, if you know your prescription you can order quality glasses from aliexpress. My latest pair cost $30us delivered, with a titanium frame and polarized lenses. So cheap that they can be more like a fashioned item than a specialty medical device.
good tip
Spending $30 on multiple pairs of glasses because they don't fit your face properly then buying different ones from aliexpress is a false economy :(
Love your teaching! You are so goofy and that is what makes it great!
how come Array(100) works without the word "new"?
You just go on speaking random stuffs but really less content 😖
Hi great video thanks for clearing up the map() method!!, just one question and forgive me if it comes across critical, it certainly isnt its just to clarify my understanding. When you compress the program down into the anonymous function within the map argument, I notice you do vals = vals.map(x => x*2); vals being the original array we are doubling. Wont this mutate the original array? sorry just going through freecodecamp which states mutating the global variables is against the concept of functional programming? im sure youre just proving a point I just wanted to check your views. thanks for the lessons though I have learnt a lot through you!!
Great question! Check the docs. The map method creates a new array. It does not mutate there original array.
Sometimes that’s wonderful. Sometimes it’s wasteful to take the time and space to create a new array.
I like your content, but your videos can be much shorter.
sir what's difference between map and filter method
lol i like how you kept going with it.. i actually do the same thing too i get caught up in these rabbit holes..
Love your videos...especially when I'm feeling frustrated and need to revisit concepts...makes my learning enjoyable :-))))) thank you :-)))))))
Why does it only choose random numbers less than 1??
hey shiffman which code block used for javascript plzz help i am big fan of u man....keep going man u are increadble
This workflow video might help:
ruclips.net/video/HZ4D3wDRaec/видео.html
Also:
sublime text: ruclips.net/video/UCHzlUiDD10/видео.html
atom editor: ruclips.net/video/d3OcFexe9Ik/видео.html
brackets: ruclips.net/video/nmZbhManVcY/видео.html
codepen: ruclips.net/video/5gfUgNpS6kY/видео.html
I would fafsa every other course but pay you from my pocket
Can you explain the line "vals.fill(0).map()" cause I'm just new to js :
Start with the docs.
Fill will take an array and replace contents with a static number. There are optional arguments to tell it which index to start and end at. So, you can say fill the array starting at index 5 and stop at index 7.
Map looks at each element performs a function a returns a new array with some kind of change.
So you started with an array. You mutated that original array with fill. Then you make a new array. Then you look at the mutated array and iterate over every element performing some actions on each element in the mutated array and place the result of those actions in order into the new array, then you return the new array.
[1,2,3,4,5].fill(‘cat’).map( x => x += ‘s’)
First I loop over the array. Each element is replaced with the string “cat”.
Then I make a new array.
Then I iterate over the modified original array, I look at each element and I add an “s” onto the end.
Then I return the new array.
[“cats”, “cats”, “cats”, “cats”, “cats”]
The original array still exists, but remember that fill changed it.
I really love the way you explain things these things. I understand it so much better now! You are a great teacher! And you are funny! :D I laughed so hard when you hit your glasses to the floor. :D I hope they are okey though. :) Keep this great tutorials coming! / Best regards from a Swedish JS noob :P
omg. so easy @@ thank you so muchhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
Would be great to have a coworker with your personality, thanks for the great videos!
Best JS guy on YT!
Thanks! 👍
A lot of methods in a short time! There is a method to the methods, apparently.
How come your videos don’t have any ads?
8:22 😂
4:33
You are better than elon musk
Would you say arrowhead functions are only particularly used for anonymous or call back functions rather than regular long functions with lots of syntax?
You are Awesome. Thank You.
Enjoyed watching your video, great passion for explaining concepts clearly
that weird scratch sound is ...ehh idk
I LOVE THE POWER *_* thaaaanks!
man, u da best in explaining, thank u :dddddd
The man knows Javascript for sure. We really benefit from you. Do you have paid courses on Udemy? If yes, please share the link to your courses.
what an energy ... good animating way of teaching... in less time teach more stuff without letting us sleep and bored..u looks more funny on 1.5X speed :p
4:55 Right after he said there are going to be more ads, I got an ad.
I'm the 1k-th liker😁😁😁😁
Map creates new glasses
Eres el puto amo!
Thank you for your funny way of teaching, very clear explications, i wish i discover your your channel earlier.
Thank you, i am trying to get to expertise level ES6. Informative and entertaining
You broke your glass :''''
Hi . You are awesome. can u plz explain exports and module.exports difference ?
You're a smart teacher ! Thanks for sharing your knowledge with us
10:50 You could also do:
vals.fill((() => Math.random())());
And I'm pretty sure it'd work the same
No, that does precisely the same as vals.fill(Math.random());
What about vals.fill(Math.random) ?
That would set all elements to be the function Math.random, which is probably not at all what you want.
if you use map on at object . It will change object, it act differently from a value. So you won't have to re assigned the value to itself
Just fabulous
Simple and to the point
You are the best thank you !
love your energy
Such a nice person :)
How much coffee and energy drinks you drinking before these vids lol