Array find and findIndex Methods in JavaScript | JavaScript Array Methods | Beginners tutorial

Поделиться
HTML-код
  • Опубликовано: 6 сен 2024
  • 🎁 Join my channel to get access to perks:
    / @codeexplained
    🧡 Hello All JavaScript Lovers Outhere!
    Today you're going to learn about the Array Object In JavaScript.
    This tutorial is a series of videos, in each video we will discuss a method (or more) of the Array Object in JavaScript.
    In today's video, you're going to learn about the find and findIndex methods.
    ------------------------------------------------ find ---------------------------------------------------------------------------------------
    The find() method returns the value of the first element that passes a test.
    The find() method executes a function for each array element.
    The find() method returns undefined if no elements are found.
    The find() method does not execute the function for empty elements.
    The find() method does not change the original array.
    🟢🟠 The Array.find().
    🔷 Syntax :
    // Callback function
    find(callbackFn)
    find(callbackFn, thisArg)
    // Inline callback function
    find(function(element) { /* … */ })
    find(function(element, index) { /* … */ })
    find(function(element, index, array){ /* … */ })
    find(function(element, index, array) { /* … */ }, thisArg)
    🔹callbackFn : Function to execute on each element.
    The function is called with the following arguments:
    🔹element : The current element being processed in the array.
    🔹index : The index of element in the array.
    🔹array : The array forEach() was called upon.
    🔹thisArg (Optional) : Value to use as this when executing callbackFn.
    ------------------------------------------------ findIndex ---------------------------------------------------------------------------------------
    The findIndex() method executes a function for each array element.
    The findIndex() method returns the index (position) of the first element that passes a test.
    The findIndex() method returns -1 if no match is found.
    The findIndex() method does not execute the function for empty array elements.
    The findIndex() method does not change the original array.
    🟢🟠 The Array.findIndex().
    🔷 Syntax :
    // Callback function
    findIndex(callbackFn)
    findIndex(callbackFn, thisArg)
    // Inline callback function
    findIndex(function(element) { /* … */ })
    findIndex(function(element, index) { /* … */ })
    findIndex(function(element, index, array){ /* … */ })
    findIndex(function(element, index, array) { /* … */ }, thisArg)
    🔹callbackFn : Function to execute on each element.
    The function is called with the following arguments:
    🔹element : The current element being processed in the array.
    🔹index : The index of element in the array.
    🔹array : The array forEach() was called upon.
    🔹thisArg (Optional) : Value to use as this when executing callbackFn.
    🌍 Social Media Links.
    ◾ Facebook : / code.explained.official
    ◾ Twitter : / code_explained
    ◾ Instagram : / code.explained.official
    ◾ GitHub : github.com/Cod...
    💲 Suppport the Channel
    Paypal : paypal.me/Code...
    Buy Me a Coffee: www.buymeacoff...

Комментарии • 4

  • @CodeExplained
    @CodeExplained  4 дня назад

    🚨 Big Announcement! 🚨
    Hey everyone! I've made a big decision for this channel-I've turned off ads on all my videos! That's right, you can now enjoy all my content ad-free! This means I'm earning $0 from ad revenue, but I believe this is the right move to make your viewing experience better.
    If you find my content valuable and want to support my work, there are several ways you can help:
    Like & Share: Simply liking the video and sharing it with friends helps a lot!
    Subscribe & Hit the Bell: Stay updated and never miss a new video.
    RUclips Thanks: Use the "Thanks" button below to send a one-time donation.
    Join the Channel Community: Get exclusive perks and behind-the-scenes content.
    Buy Me a Coffee: buymeacoffee.com/CodeExplained
    PayPal Donation: www.paypal.com/paypalme/CodeExplained
    Every little bit counts and goes directly to creating more high-quality content for you all. Thank you so much for your continued support!
    Let’s keep growing and learning together! 🌟

  • @daoudamed
    @daoudamed 2 года назад +2

    Good tutorial.
    Your teaching style is great.

  • @fightscene817
    @fightscene817 2 года назад +2

    great tutorial! Thank you

  • @tamerahmed9860
    @tamerahmed9860 2 года назад +1

    Thank you