Vineeth.mariserla has Published 140 Articles

How to empty an array in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

There are a couple of ways to empty an array in javascript.Let's suppose take an arrayvar array1 = [1, 2, 3, 4, 5, 6, 7];Method 1var array1 = [];The code above will set the number array to a new empty array. This is recommended when you don't have any references ... Read More

How to check whether a key exist in JavaScript object or not?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

There are a couple of ways to find whether a key exist in javascript object or not.Let's say we have an 'employee' object as shown below.   var employee = {       name: "Ranjan",       age: 25    }Now we need to check whether 'name' property exist ... Read More

How to access a function property as a method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

Accessing a function as a method A javascript object is made up of properties. To access a property as a method, just define a function to a property and include other properties in that function.In the following example an object called "employee" is created with properties "fullName", "lastName" , "firstName" and ... Read More

How to hide e-mail address from an unauthorized user in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

Hiding an e-mail addressThe following steps are to be followed to hide our e-mail from unauthorized users. In every email address '@' symbol is common so try to remove it from the email address using split() method. In the following example after splitting the email(batman@gmail.com) we get the result as batman, gmail.com.Divide ... Read More

How to check if a variable is an array in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

In javascript we can check whether a variable is array or not by using three methods.1) isArray() methodThe Array.isArray() method checks whether the passed variable is array or not. If the variable is an array it displays true else displays false.SyntaxArray.isArray(variableName)ExampleLive Demo arr = [1, ... Read More

What is the use of Map in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

MapMap holds key value pairs and remembers the actual insertion order of the keys. Map allows to store only a unique value.syntaxnew Map([iterable])Case-1: Absence Of MapIn the absence of Map, since javascript object endorses only one key object, If we provide multiple keys only the last one will be remembered. ... Read More

Explain the importance of Array.filter() method in JavaScript with example?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

Array.filter()Array.filter() method creates a new array with all the elements that have passed the test implemented by the provider function(function given by the user).In the following example the test is whether the given salary elements are more than a particular value(19000) given by the user().Example-1Live Demo   ... Read More

How to remove non-word characters in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

Removing non-word charactersTo remove non-word characters we need to use regular expressions. The logic behind removing non-word characters is that just replace the non-word characters with nothing('').ExampleIn the following example there are many non-word characters and in between them there exists a text named "Tutorix is the best e-learning platform". ... Read More

What is the use of Array.Reduce() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

Array.Reduce()The Array.Reduce() method executes the provided function(given by the user) to each element of the array, there by giving single output.In the given example, the provided function(function provided by user is addition) executes on each element of the array(1, 2, 3, 4) there by returning a single output (10).Example Live Demo ... Read More

How to decode an encoded string in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jul-2019 22:30:26

DecodingIn JavaScript, to decode a string unescape() method is used. This method takes a string, which is encoded by escape() method, and decodes it. The hexadecimal characters in a string will be replaced by the actual characters they represent using unescape() method.Syntaxunescape(string)ExampleIn the following the two exclamation marks have converted ... Read More

Advertisements