Menu

How to get a segment from a URL using JS?

We can find a text or get a segment from a URL or web address using the JS split and slice function. Below is an example of a slice and split function in simple JavaScript code.

Lets assume we have a URL: https://rashidjorvee.blogspot.com/content/2015/javascript:getName_function/12032/live.html

When we run the split based on colon(:) it will return as below.

e.g. window.location.href.split(":").pop()

result ==> getName_function/12032/live.html

Now, from this if you want to read only few characters from any index, then do the slice on the URL.

e.g. window.location.href.split(":").pop().slice(0,7);

result ==> getName

How to read any attribute value using the element class name using JS?

Using the DOM function we could find the element using class name and then from that search list go to first index and get the required attribute.

document.getElementsByClassName('class_name')[0].getAttribute('id');

SQL queries to perform CURD operations

Standard Query Language is frequently referred to as SQL queries are the statement to create, update and delete the records from the database table in SQL and NoSQL database.

Let's understand the different types of queries that we use to perform operations in the database table. 


SELECT * FROM "user"
WHERE enabled = 'false'


SELECT * FROM "user"
WHERE email IN ('yumfawa48@gmail.com','rashid.jorvee@gmail.com')


UPDATE "user"
SET enabled='true'
WHERE id='sql-tutorial'