slice vs substring method | String Object In JavaScript

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ค. 2022
  • 🎁 Join my channel to get access to perks:
    / @codeexplained
    🧡 Hello All JavaScript Lovers Outhere!
    Today you're going to learn about the String Object In JavaScript.
    This tutorial is a series of videos, in each video we will discuss a method (or more) of the String Object in JavaScript.
    In today's video, you're going to learn about two string methods, slice and substring, and know the difference between them.
    Both slice and substring extract a section of a string and return it as a new string, without modifying the original string.
    Syntax:
    slice(indexStart)
    slice(indexStart, indexEnd)
    substring(indexStart)
    substring(indexStart, indexEnd)
    indexStart is : The index of the first character to include in the returned substring.
    indexEnd is : The index of the first character to exclude from the returned substring.
    🌍 Social Media Links.
    ◾ Facebook : / code.explained.official
    ◾ Twitter : / code_explained
    ◾ Instagram : / code.explained.official
    ◾ GitHub : github.com/CodeExplainedRepo
    💲 Suppport the Channel
    Paypal : paypal.me/CodeExplained
    Buy Me a Coffee: www.buymeacoffee.com/CodeExpl...

ความคิดเห็น • 32

  • @suryasvibe1941
    @suryasvibe1941 ปีที่แล้ว +3

    This is how an explanation should be ❤👍

  • @shweta8932
    @shweta8932 4 หลายเดือนก่อน +2

    You explained in the way no one did before u.... thnk u..
    😊

  • @NYC_CuriousG
    @NYC_CuriousG ปีที่แล้ว +5

    Wow!! I'm a visual learner and this really helped me. Thanks for taking the time and effort to make this. Well thought out. If you do something like this again it might help a beginner to understand some use cases. Subscribed!

  • @shumonuddin6806
    @shumonuddin6806 ปีที่แล้ว +6

    wow wow wow... it's so easy to understand the way you explain... thank you so much

  • @indranathghosh5327
    @indranathghosh5327 7 หลายเดือนก่อน +3

    perfect to to the point . nice video

  • @bradderzthebell
    @bradderzthebell 4 หลายเดือนก่อน

    Brilliant video. I was reading the differences on w3 Schools and just wasn't getting it. This way of visualising it and pointing out the differences really made it easy to learn. Thank you!

  • @maverickansh
    @maverickansh 10 หลายเดือนก่อน +1

    thanks man i was reading mdn docs for this but i got better understanding here.

  • @codexakshay2348
    @codexakshay2348 3 หลายเดือนก่อน

    Best Explanation. Thank you.

  • @Yan-oe2mw
    @Yan-oe2mw 10 หลายเดือนก่อน

    best illustration i have ever seen

  • @vinaypatil8009
    @vinaypatil8009 ปีที่แล้ว +3

    Make whole javascript series
    Teaching with animation is really look awesome

  • @mdhabibullaharafatridoy9288
    @mdhabibullaharafatridoy9288 ปีที่แล้ว +1

    Beautifully explained. Thank you so much.

  • @Devanetworks
    @Devanetworks ปีที่แล้ว +1

    you are the best😩 i love u

  • @ibex33
    @ibex33 7 หลายเดือนก่อน +1

    excellent explanation, thanks brother.

  • @stephen1569
    @stephen1569 ปีที่แล้ว +1

    All negative numbers in substring() are treated as 0. It is interesting that this makes substring(-8, -4) functionally equivalent to substring(0, 0) in that they both return an empty string. The empty string is everywhere and is a subset of every string!!
    For substring(), if start is greater than end, arguments are swapped: (4, 1) = (1, 4).
    So, for positive numbers, substring() will work in BOTH directions ( LTR and RTL ).
    For both positive and negative numbers, slice() WILL NOT work in direction RTL, even if characters exist in that space, i.e. it returns the empty string.

  • @cailarchitectatopks
    @cailarchitectatopks 5 หลายเดือนก่อน

    Crystal clear.

  • @TheRaihaan1
    @TheRaihaan1 9 หลายเดือนก่อน

    excellent explanation

  • @shakil-the-coding-monster
    @shakil-the-coding-monster ปีที่แล้ว

    Excellent explanation

  • @juancaca1993
    @juancaca1993 ปีที่แล้ว +1

    Very well explained!!!!! new sub ^^ I didn't know about that negative line of numbers, do you know how it is called?

  • @selvaganeshm1914
    @selvaganeshm1914 9 หลายเดือนก่อน

    best video.

  • @diatm1506
    @diatm1506 8 หลายเดือนก่อน

    Very good djobs

  • @ragularvind5906
    @ragularvind5906 ปีที่แล้ว +2

    Negative index for slice doesn't work that way

  • @truthfinder3084
    @truthfinder3084 ปีที่แล้ว +1

    ❤ It's awesome...
    Can you share which application you used for create this animation?.

  • @Zer0Cr4ckxd
    @Zer0Cr4ckxd 5 หลายเดือนก่อน

    ty

  • @volodymyrpivtoranis6648
    @volodymyrpivtoranis6648 ปีที่แล้ว +1

    Thank you 🙏🏼

  • @igu642
    @igu642 10 หลายเดือนก่อน

    ❤❤

  • @luckybeast4757
    @luckybeast4757 5 หลายเดือนก่อน

    Super

  • @devamrh
    @devamrh 6 หลายเดือนก่อน

    Which software do you use ?

  • @shikharana1587
    @shikharana1587 5 หลายเดือนก่อน

    this is not correct information. in slice indexEnd value is not included in the result. please verify the result and update the video accordingly. i request not to provide wrong information. though i like you way of presentation.

    • @CodeExplained
      @CodeExplained  5 หลายเดือนก่อน

      You made me watch my own video.
      And it's your turn to do so.
      Please re-watch the video, cause I don't see where I said that indexEnd is included and not excluded.