If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
slice() method , दिए गए start - end argument के according elements को select करके एक new Array Object return करता है। हालाँकि इससे original Array में कोई changes नहीं आते हैं।
array.slice(start : int, end : int);
start | required : यह starting value है , जहाँ से Array elements को select करना है। input value का type integer होना चाहिए।
end | optional : यह end value है , जहाँ तक Array elements को select करना है।इसका type भी integer होना चाहिए।
Return Value : दिए गए input के according , एक selected elements का एक new Array return करता है।
File : js_array_slice.html
<!DOCTYPE html>
<html>
<body>
<script>
let languages = ["PHP", "Java", "JavaScript", "Python", "Ruby", "React JS", "React Native"];
/*It will select from array indx 2 to end*/
document.write(languages.slice(2));
/*line break*/
document.write("<br>");
/*It will select from array indx 2 to 3 : end*/
document.write(languages.slice(2, 4));
document.write("<br>");
document.write("Original Array : " + languages);
</script>
</body>
</html>
JavaScript,Python,Ruby,React JS,React Native JavaScript,Python Original Array : PHP,Java,JavaScript,Python,Ruby,React JS,React Native
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook