Similarly, there was no direct feature in javascript for deconstructing or extracting multiple data at a time until ES6 introduced destructuring. Let's see the same example. » C++ // Function to return 2 consecutive numbers, Run-length encoding (find/print frequency of letters in a string), Sort an array of 0's, 1's and 2's in linear time complexity, Checking Anagrams (check whether two string is anagrams or not), Find the level in a binary tree with given sum K, Check whether a Binary Tree is BST (Binary Search Tree) or not, Capitalize first and last letter of each word in a line, Greedy Strategy to solve major algorithm problems. » Java First we need to store all the elements that we want to return from the function in the array. » CS Basics JavaScript arrays are easily one of my favorite data types. Compare it with a cup, for example. For example, threeNumbers.first is easy to understand which says first of the three numbers. Then I create var i and use a for loop to go through and change all of their CSS value. Objects in JavaScript, just as in many other programming languages, can be compared to objects in real life. First their HTML code. Returning multiple values from a function using an array. The typeof operator in JavaScript returns "object" for arrays. Interview que. But how can you attach the same event to multiple elements? There are a couple of related functions that will return an array of elements – getElementsByName, or getElementsByClassName that may be more suited to your requirements, though getElementsByClassName is new to HTML 5, … The push method appends values to an array.. push is intentionally generic. » Cloud Computing . Using the object method, we can select the element explicitly. Some functions return just one value.