Menu

Get page or file name from URL using JavaScript

Read the path of the current browsing page from DOM using the below JavaScript statement. Let's assume the URL of the page is "https://rashidjorvee.blogspot.com/2020/07/remote-debugger-in-eclipse.html"

var path =window.location.pathname;


After running the above statement value of path will return "/2020/07/remote-debugger-in-eclipse.html"

Now, split the path with slash(/) to get the last occurrence, which will be the final page name URL.

var page = path.split("/").pop();

After running the above statement the value of the page will be "remote-debugger-in-eclipse.html"

Now, if we want to remove the extension .html then run the below statement which will manipulate the value of the page variable.

var name = page.substr(0, page.lastIndexOf('.'));

After running the above statement the value gets assigned to the name variable "remote-debugger-in-eclipse"

What is interface in java?

An interface is a complete abstraction, which helps us expose the methods that can be invoked by the outer world that derive the interface(subclasses). In general terms, the interface is for hiding the data.

Types of Interface


Functional interface: A interface that has only one abstract method. It may have other static and default methods. you can leave the name while implementing the name of the method because an interface contains only one abstract method.

Marker interface: A interface without any method. This is to add on some special functionality to the class so the compiler can treat that class in different ways.

Generic interface: A interface that is general like a class and has variables, methods, and constructors.

How to fetch and checkout a git branch?

Git is a version control system that is used to store and manage the codebase. A branch from Git can be checkout using Git command > git checkout <branch_name>.

A new branch can be fetch and checkout using below git command.

git fetch && git checkout feature/social_sign


Git version control for programmer