slice vs substring method | String Object In JavaScript

preview_player
Показать описание
🎁 Join my channel to get access to perks:

🧡 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.

💲 Suppport the Channel
Рекомендации по теме
Комментарии
Автор

This is how an explanation should be ❤👍

Surya_Kiran_K
Автор

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

shweta
Автор

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!

bradderzthebell
Автор

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!

NYC_CuriousG
Автор

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

shumonuddin
Автор

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

maverickansh
Автор

excellent explanation, thanks brother.

ibex
Автор

Make whole javascript series

Teaching with animation is really look awesome

vinaypatil
Автор

Beautifully explained. Thank you so much.

mdhabibullaharafatridoy
Автор

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.

stephen
Автор

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

juancaca
Автор

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

truthfinder
Автор

Negative index for slice doesn't work that way

ragularvind
Автор

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.

shikharana