The onpageshow event triggers in JavaScript when a user reaches the new web page.ExampleYou can try to run the following code to learn how to implement onpageshow event in JavaScript. On first visit, a welcome message is visible. function newFunc() { alert("Welcome!"); }
When anchor part is changed, then the onhashchange event occurs. You can try to run the following code to learn how to implement onhashchange event in JavaScript.Example Click to change anchor function functionChange() { location.hash = "about"; var hash = location.hash; document.write("The anchor part is now: " + hash); } // If the achor part is changed function newFunc() { alert("Anchor part changed!"); }
To stop the execution of a function in JavaScript, use the clearTimeout() method. This function call clears any timer set by the setTimeout() functions.ExampleYou can try to run the following code to learn how to work with clearTimeout() method in JavaScript. JavaScript clearTimeout() method Click the buttons below to handle animation
Use the on abort event to abort the loading of an image. You can try to run the following code to learn how to implement an abort event in JavaScript.Example function abortFunc() { alert('Error- Loading of the image aborted'); }
As part of data analysis using Python we may be required to to convert the data container from set to list. In this article we'll see e how to solve this requirement.With listThis is a straightforward approach in which we directly apply the list function on the given set. The elements get converted into elements of a list.Example Live DemosetA = {'Mon', 'day', '7pm'} # Given Set print("Given set : ", setA) res = (list(setA) ) # Result print("Final list: ", res)OutputRunning the above code gives us the following result −Given set : ['7pm', 'Mon', 'day'] Final list: ['7pm', 'Mon', 'day']With ... Read More
As part of data manipulation in Python we may sometimes need to convert a given number into a list which contains the digits from that number. In this article we'll see the approaches to achieve this.With list comprehensionIn the below approach we apply the str function to the given number and then convert into integer through identity function. Finally we wrap the result into a list.Example Live DemonumA = 1342 # Given number print("Given number : ", numA) res = [int(x) for x in str(numA)] # Result print("List of number: ", res)OutputRunning the above code gives us the following result −Given ... Read More
During data processing using python, we may come across a list whose elements are tuples. And then we may further need to convert the tuples into a list of strings.With joinThe join() returns a string in which the elements of sequence have been joined by str separator. We will supply the list elements as parameter to this function and put the result into a list.Example Live DemolistA = [('M', 'o', 'n'), ('d', 'a', 'y'), ('7', 'pm')] # Given list print("Given list : ", listA) res = [''.join(i) for i in listA] # Result print("Final list: ", res)OutputRunning the above code gives ... Read More
Sometimes we may be given a python list whose elements are tuples. Then we may have a data processing requirement which will need these tuples to be converted to lists for further processing. In this article, we will see how to convert a list of tuples to a list of lists.With list comprehensionIt is a straight forward approach where we create a for loop to loop through each element and apply the list function to create a list of lists.Example Live DemolistA = [('Mon', 3), ('Wed', 4), ('Fri', 7, 'pm')] # Given list print("Given list : ", listA) res = [list(ele) ... Read More
We may come across a lists whose elements are tuples. But for further data processing we may need to convert the tuples to the normal elements of a list. In this article we will see the approaches to achieve this.With list comprehensionIn this approach we design nested for loops to iterate through each tuple and produce the final list of elements.Example Live DemolistA = [('Mon', 3), ('Wed', 4), ('Fri', 7, 'pm')] # Given list print("Given list : ", listA) res = [item for t in listA for item in t] # Result print("Final list: ", res)OutputRunning the above code gives us ... Read More
Python has a wide variety of data manipulation capabilities. We have a scenario in which we are given a list which has elements which are pair of numbers as tuples. In this article we will see how to extract the unique digits from the elements of a list which are tuples.With re and setWe can use regular expression module and its function called sub. It is used to replace a string that matches a regular expression instead of perfect match. So we design a regular expression to convert the tuples into normal strings and then apply the set function to ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP