split method spilt the string into array of substring based on the pattern provided.
let numbersStr = "1,2,3,4,5";let numArray = numbersStr.split(",");console.log(numArray); // ["1","2","3","4","5"]
In the above example , the split method will loop through all the character of the string , if the pattern provided is found then the split method will collect the characters looped before finding the pattern and join all the characters as a string and pushed that string into an array .
If we don’t pass any pattern then the entire string will be pushed to an array and…
XHRwe can update the page based on the user action.
XHR, we can make both synchronous and asynchronous requests.
let request = new XMLHttpRequest();
To configure the request, we can use the
open method of
XMLHttpRequest object. …
You can use
method to check if a primitive value present in an array , Consider we have an array
var num = [1,2,3,4,5];
indexOf() method returns the first index of the element in the array, if the searching element is not present in the array then it returns
num.indexOf(3); // 2num.indexOf(6); //-1num.indexOf('3'); // -1
NaN value is not handled in
var array = [NaN];array.indexOf(NaN); // -1
If your array can contain
NaN , then you can use
Requesting donation for my Badminton Training.
Hello Reader, My name is Jagathish Saravanan, I am from India. I am currently working as a Web developer , I love my Job , but once I started playing Badminton , I started loving Badminton more that anything , So I have decided to switch my carrer to Badminton, It is hard to manage my training expense , so I started writing Blog in Medium . But medium partner program is not supported in India. So I am requesting you to donate some amount .
You can donate me in PayPal :
Google pay: 8015851838.
Thank you so much for your time
These are the articles that are freshly created this week. I hope you like this
Learn how to generate ASCII art from the image using Python.
Steps to convert image to ASCII character
To load the image we will be using
path = input("Enter the path to the image fiel : \n")
image = PIL.Image.open(path)
print(path, "Unable to find image ");
The above code read the image from the path given by the user. …
Learn how to add new columns to the table in PostgreSQL
We can combine
ALTER TABLE &
ADD COLUMN to add new columns to an existing table.
ALTER TABLE table_name
ADD COLUMN column_name1 data_type,
ADD COLUMN column_name1 data_type,
Let’s say we have a table
user , with
age . Now we need to add a new column
alter table user
add column phone_number bigint;
Consider we need to add two more columns,
ALTER TABLE user
ADD COLUMN salary int,
ADD COLUMN nickname varchar;
With Postgres 9.6 this can be done using the option
slice method of
array returns a shallow copy of a portion of the array based on the
end index passed.
Points to remember
endis an optional argument
endis index is not considered, means if you
slicean array passing
startas 0 and
endas 5 then, elements from
4thindex will be copied
slicedoesn’t affect the
sourcearray from which we are performing
endindex, which indicates an offset from the end of the array. …
Notification API you can display a notification on your website.
Three simple steps to show system notification
Check Browser support
typeof Notification !== "undefined"
Before asking permission, let’s check if the permission is already granted. To get the notification permission, you can use
It can have 3 values
denied→ Permission granted
granted→ Permission granted
default→The user choice is unknown and therefore the browser will act as if the value were denied. …