toString() এবং split('/') ব্যবহার করে URL কে পার্টগুলোর অ্যারেতে ভাগ করা যায়।
উদাহরণ
var newURL = "https://www.example.com/index.html/homePage/aboutus/";
console.log(newURL);
var splitURL = newURL.toString().split("/");
console.log(splitURL);
কমান্ড: node fileName.js
আউটপুট
PS C:\Users\Amit\JavaScript-code> node demo150.js https://www.example.com/index.html/homePage/aboutus/ [ 'http:', '', 'www.example.com', 'index.html', 'homePage', 'aboutus', '' ]