In this tutorial, we will learn how to get the value of the target attribute of a link in JavaScript. The target attribute specifies where to open the linked document or page. By default, its value is set to ‘_self, ’ which means the linked document should open in the same window or tab. It can also have values like ‘_blank, ’ ‘_self, ’ ‘_parent, ’ ‘_top, ’ and ‘frame_name’, where each value defines a different location to open the linked document. Using the target property To get the value of the target attribute of a link in JavaScript, use ... Read More
In this tutorial, we will learn how to get the number of seconds between two dates with JavaScript. There are different methods for checking the number of days, hours, and seconds that are commonly used to provide information related to data. Since you can’t manually change the count of the years and months, we follow some simple tricks to get the number in JavaScript. Using the Date getTime() Method In JavaScript, we use different methods to calculate the days, hours, and seconds. Most popular way to calculate the time is .getTime(). However, you will get the result in milliseconds and ... Read More
In this article, we will explain PEP8 and its uses in python. Also, we will see its advantages while coding. What is PEP8? PEP is an abbreviation for Python Enterprise Proposal. Writing code with good logic is a crucial aspect of programming, but many other important elements can affect the quality of the code. The developer's coding style makes the code more reliable, and every developer should remember that Python rigidly follows the string's order and format. A good coding style makes the code more readable. The code is simplified for the end user PEP 8 is a document that ... Read More
The Python language has a different way of representing syntax and default values for function arguments. Default values indicate that if no argument value is given during the function call, the function argument will take that value. The default value is assigned by using the assignment (=) operator of the form keywordname=value. Example # creating a function by giving default values def tutorialspoint(website, author ='XYZ', language ='Python'): print(website, "website article is written by the author", author, "of language", language) Function call without keyword arguments Example # creating a function by giving default values def tutorialspoint(website, author ... Read More
In this article, we will explain to you the mutable and immutable objects in python. Python considers everything to be an object. A unique id is assigned to it when we instantiate an object. We cannot modify the type of object, but we may change its value. For example, if we set variable a to be a list, we can't change it to a tuple/dictionary, but we may modify the entries in that list. In Python, there are two kinds of objects. On the one hand, there are objects that can change their internal state (the data/content inside ... Read More
In this article, we will show you the Python's map(), filter(), and reduce() functions add a touch of functional programming to the language. All three of these are convenience functions that can be replaced with List Comprehensions or loops but offer a more elegant and concise solution to some problems. map(), filter(), and reduce() all work in the same way. These functions accept a function and a sequence of elements and return the result of applying the received function to each element in the sequence. map() function Like reduce(), the map() function allows you to iterate over each item in ... Read More
In this article, we will explain to you the differences between indexing and slicing in python. Indexing and slicing are applicable only to sequence data types. The order in which elements are inserted is preserved in sequence type, allowing us to access its elements via indexing and slicing. To summarise, Python's sequence types are list, tuple, string, range, byte, and byte arrays. And indexing and slicing are applicable to all of these types. Indexing The term "indexing" refers to refers to an element of an iterable based on its position inside the iterable. The indexing begins from 0. The ... Read More
In this tutorial, we will learn how to preselect a select list item using JavaScript. It is given an id attribute to be associated with a for accessibility purposes and a name attribute represents the name of the associated data point submitted to the server. element nestled inside the is used to define each menu option. Each element have a value attribute that contains the data value to submit to the server when that option is selected. If no value attribute is specified, the value is set to the text contained within the element.You can include ... Read More
In this tutorial, we will learn how to invoke a JavaScript Function with the 'new' Function Constructor. Functions are a set of reusable codes that perform a specific task and may return a value. In JavaScript, functions are defined by the keyword function. A function may not have any parameters and may also not have any return statement. In JavaScript, we also have functions with no function names, called anonymous functions Using the 'new' Function Constructor The Function constructor makes a new Function object. By using the constructor, we can create a function dynamically. It takes parameters, or arguments, and ... Read More
In this tutorial, we will learn how to invoke a JavaScript Function as a method. In JavaScript, the code inside a function will execute when the function is invoked. We can invoke a function in a variety of ways. One of them is using the method. The method is a property of an object that has a function value. We can define functions as object methods. This function will have a function name, a parameter (optional), and a return type (optional). It will have a "this" keyword which refers to an object. Users can follow the syntax below to declare ... Read More