
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 6710 Articles for Javascript

1K+ Views
In this article, we are going to discuss about the super keyword in JavaScript with suitable examples. The Super keyword is basically used in Object Oriented Programming. The Super keyword is used to call parameters and functions of an object’s parent. There are times a parent class and sub class can have same method names and parameter names. In those case, to avoid confusion between the parent class and sub class method names or parameter names, super keyword is used. In order to use a Super keyword, the child method must extend the parent class method. Syntax The syntax to ... Read More

53K+ Views
Sleep()With the help of sleep() we can make a function to pause execution for a fixed amount of time. In programming languages such as C and PHP we would call sleep(sec). Java has thread.sleep(), Python has time.sleep() and Go has time.Sleep(2 * time.Second).JavaScript doesn't have these kinds of sleep functions. But we should thank promises and async/await function in ES 2018. Because these features have helped us to use sleep() as easy as possible. Let's discuss it in a nutshell.syntax-1sleep(Time in ms).then(() => { //// code })We can use the sleep function with then call back as shown above.syntax-2const work = async () => { await sleep(Time in ... Read More

681 Views
Object.assign()This method is used to copy one or more source objects to a target object. It invokes getters and setters since it uses both 'get' on the source and 'Set' on the target. It returns the target object which has properties and values copied from the target object. This method does not throw on null or undefined source values.syntaxObject.assign(target, ...source objects);It takes source objects and a target object as parameters and push the source objects into the target object and display the target object.Example-1In the following example, the properties from the source objects "obj1", "obj2", and "obj3" were pushed into ... Read More

167 Views
In this article, the given task is to execute digits in even places in a JavaScript array with suitable examples. To execute the digits in even places in a JavaScript array, we need to get the starting index of the array and we need to loop through it by checking whether the index is at odd place or even place. Using the filter() Method: This method will create a new array filled with elements that pass a test provided by a specified function. This method doesn’t execute the function for empty elements and this method do not modify the original ... Read More

155 Views
The key-value pairs are stored using JavaScript WeakMap Objects. A WeakMap object differs from a Map object in that such objects should be weakly referred and "object" should be stored in the WeakMap object as a key. In comparison, you can add simple values like strings, booleans, symbols, and numbers to the Map objects. WeakMap objects are stored loosely, therefore if the references to a particular key are dropped or the object is erased, the garbage collection will drop the WeakMap element after it has verified that the value is mapped to the relevant object. The JavaScript built-in function weakMap.has() ... Read More

772 Views
An array is a group of elements. Each element has its own index value. We can access any element using these indexes. But in the case of the last element, we don't know the index until we know the number of elements present in the array. In this case, we have to use logic. Let's discuss these details in a nutshell.Accessing the first elementSince we know the index of the first element we can get the value of that element very easily. Let the array be arr. then the value of the first element is arr[0].ExampleIn the following example, there are ... Read More

318 Views
Javascript arrays are 0-indexed. This means that the first element is at the 0th position. The last element is at the length-of-array - 1th position. So we can access these elements using −Examplearr[0] // First element arr[arr.length - 1] // last element For example, let arr = [1, 'test', {}, 'hello'] console.log(arr[0]) console.log(arr[arr.length - 1])Output1 hello

7K+ Views
This article discusses about how “getElementByID” method work in JavaScript. The getElementByID() method in JavaScript is a document method. When we give a specific string which should match the ID of the HTML element, it returns the element object. Every HTML element can be assigned a unique ID. If two or more elements have the same ID, then the getElementByID() method returns the first element. The getElementByID() method is used for the faster access of an element. It helps us to manipulate an HTML element within our document and is supported by all the modern browsers. If the element is ... Read More

2K+ Views
To remove an element from an array with JavaScript, use the shift() and pop() functions. However, there is a slight distinction among them. While pop() removes the last element from an array, shift() removes the first element from an array. When using the shift() method, the value that was deleted is returned after the element at the zeroth position is removed and values at subsequent indexes are shifted downward. The return value is undefined if the length property is 0. A function that modifies data is shift(). Both the substance and the length of this are altered. Use arr.slice(1) instead ... Read More

7K+ Views
The document's current title can be obtained or changed using the document.title attribute. When present, the value of the is used by default. You can change or get the current title of the document using the document.title attribute. By providing a new title as a string to this attribute, the page's title can be changed. The chosen title will immediately be reflected in the website's title. In this article you will see two types of methods used to change or use Document.title() use in JavaScript Using the document.title property − You may set or get the current title ... Read More