Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does the number 1 do in this code

I understand (I think) that this JavaScript splits on the hash tag, but what would the 1 represent?

window.location.hash.split("#")[1];
like image 704
mjmitche Avatar asked Jun 12 '26 14:06

mjmitche


1 Answers

The split() method is used to split a string into an array of substrings, and returns the new array. Thus, the [1] represents the second element of the split array window.location.hash.split("#")[1];

JavaScript Split Function

like image 104
KJYe.Name Avatar answered Jun 15 '26 03:06

KJYe.Name



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!