Role of scrollY Property in JavaScript

Ayyan
Updated on 20-May-2020 11:02:34

418 Views

The scrollY property in JavaScript works the same as pageYoffset property. If you want to get the pixels the document scrolled to from the upper left corner of the window, then use the scrollY property for vertical pixels.ExampleYou can try to run the following code to learn how to work with scrollY property in JavaScript.                    div {             background-color: yellow;             height: 1500px;             width: 1500px;          }                              function scrollFunc() {             window.scrollBy(200, 200);             alert("Vertical: " + window.scrollY);          }             Scroll                      

Role of scrollX Property in JavaScript

Srinivas Gorla
Updated on 20-May-2020 11:01:25

602 Views

The scrollX property in JavaScript works the same as pageXoffset property. If you want to get the pixels the document scrolled to from the upper left corner of the window, then use the scrollX property for horizontal pixels.ExampleYou can try to run the following code to learn how to work with scrollX property in JavaScript.                    div {             background-color: yellow;             height: 1500px;             width: 1500px;          }                              function scrollFunc() {             window.scrollBy(200, 200);             alert("Horizontal: " + window.scrollX);          }             Scroll                      

Work with Document Images in JavaScript

Arushi
Updated on 20-May-2020 11:00:53

527 Views

Use the document.images property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.images property in JavaScript.Live Demo           JavaScript Example               TutorialsPoint Tutorials                            var num = document.images.length;          document.write("How many images? "+num);          

Convert List of Strings to List of Tuples in Python

Pradeep Elance
Updated on 20-May-2020 10:59:26

387 Views

While manipulating data with python, we may come across a list which has numbers as strings. Further we may want to convert the list of strings into tuples. Of course the given strings are in a particular format of numbers.With map and evalWe will use the map function to apply eval on every element of the list. Then store the final element as a list.Example Live DemolistA = ['21, 3', '13, 4', '15, 7'] # Given list print("Given list : ", listA) # Use eval res = list(map(eval, listA)) # Result print("List of tuples: ", res)OutputRunning the above code gives us ... Read More

Convert List of Strings and Characters to List of Characters in Python

Pradeep Elance
Updated on 20-May-2020 10:58:15

489 Views

While dalign with lists, we may come across a situation where we have to process a string and get its individual characters for further processing. In this article we will see various ways to do that.With list comprehensionWe design a for loop to go through each element of the list and another loop inside this to pick each character from the element which is a string.Example Live DemolistA = ['Mon', 'd', 'ay'] # Given lists print("Given list : ", listA) # Get characters res = [i for ele in listA for i in ele] # Result print("List of characters: ", res)OutputRunning ... Read More

Convert List of String into Sorted List of Integer in Python

Pradeep Elance
Updated on 20-May-2020 10:55:48

532 Views

Analysing data using python can bring us scenario when we have to deal with numbers represented as strings. In this article we will take a list which has numbers present as strings and we need to convert then to integers and then represent them in a sorted manner.With map and sortedIn this approach we apply the int function to every element of the list using map. Then we apply the sorted function to the list which sorts the numbers. It can handle negative numbers also.Example Live DemolistA = ['54', '21', '-10', '92', '5'] # Given lists print("Given list : ", listA) ... Read More

Convert List of Numerical String to List of Integers in Python

Pradeep Elance
Updated on 20-May-2020 10:53:29

371 Views

For data manipulation using python, we may come across scenario where we have strings containing numbers in a list. To be able to make calculations, we will need to change the strings into numbers. In this article we will see the ways to change the strings into numbers inside a list.With intThe int function can be applied to the string elements of a list converting them to integers . We have to carefully design the for loops to go through each element and get the result even if there are multiple strings inside a single element.Example Live DemolistA = [['29', '12'], ... Read More

Convert Dictionary Object into String in Python

Pradeep Elance
Updated on 20-May-2020 10:51:52

386 Views

For data manipulation in python we may come across situation to convert a dictionary object into a string object. This can be achieved in the following ways.with str()In this straight forward method we simple apply the str() by passing the dictionary object as a parameter. We can check the type of the objects using the type() before and after conversion.Example Live DemoDictA = {"Mon": "2 pm", "Wed": "9 am", "Fri": "11 am"} print("Given dictionary : ", DictA) print("Type : ", type(DictA)) # using str res = str(DictA) # Print result print("Result as string:", res) print("Type of Result: ", type(res))OutputRunning the above ... Read More

Work with Document Embeds in JavaScript

Jai Janardhan
Updated on 20-May-2020 10:51:40

205 Views

Use the document.embeds property in JavaScript to get the number of tags in a document.ExampleYou can try to run the following code to implement document.embeds property in JavaScript.Live Demo           JavaScript Example                              var num = document.embeds.length;          document.write("How many embed tags: "+num);          

JavaScript Bitwise XOR Operator

Abhinaya
Updated on 20-May-2020 10:50:12

295 Views

If both the bits are different, then 1 is returned when Bitwise OR (|) operator is used.ExampleYou can try to run the following code to learn how to work with JavaScript Bitwise XOR Operator.                    document.write("Bitwise XOR Operator");          // 7 = 00000000000000000000000000000111          // 1 = 00000000000000000000000000000001          document.write(7 ^ 1);          

Advertisements