Reverse a string in javascript using reverse()
hi everyone in this video i'm going to demonstrate you how we can reverse a string in javascript so let's get started with the implementation part and i'll declare a string over here let's see the string name is saucer then let me just directly create a function which will give me the reverse string and name of my function is time text system and from here i can directly return the string after splitting and then i'll use the reverse function of javascript and i will join everything and now i will be calling this function over here and passing the string i have declared on top if we execute this so this is my return strength and we can also test a sentence over here which contains character spaces so if i execute this code now so this is the reverse string of the string which i gave over there and there is one more way we can use a string so let me create another function and what i'm going to do in this case is i'm going to use spread operator over here so if i'm using spread operator i don't need to use split function i will simply call reverse and join and now i am going to replace my function call with the string part 2 and if i click change the sentence today is an awesome day and if i click on learn it still executes in the same way so both the methods which we have seen today are not the most efficient ones when we are trying to reverse a string and these run a bit slow as compared to other methods which we have available so we will be discussing about those in my upcoming videos so thanks for watching and stay safe and stay healthy bye
https://www.youtube.com/watch?v=1KbQICfmP4o