Vineeth.mariserla has Published 117 Articles

In how many ways can we split a string in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:51:27

319 Views

In javascript, we can split a string in 3 ways. One is an old way in which string.split() method is used and later on, ES6 has provided 2 more ways to split a string. In the first way spread operator is used and in the second way array.from() method is used. Let's ... Read More

How to swap variables with destructuring in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:46:43

144 Views

Swapping variables has become very easy with destructuring. In contemporary javascript swapping takes place by using another variable. It may not be hectic but it is lengthy. But in modern javascript there is no need for the third variable. Let's discuss it in detail.Example-1In the following example, swapping has done using another variable ... Read More

What is the importance of str.padStart() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 15:31:18

104 Views

We can attach two strings using the concat() method. But if we need to attach a specific string at the starting of the first string then the easiest way is string.padStart(). This method not only adds the second string at the start of the first string but also looks after the ... Read More

Is it possible to change the HTML content in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 30-Jun-2020 08:52:32

1K+ Views

Yes, it is possible to change the content of the HTML in javascript. Usually HTML content will be in HTML tags such as , , etc. In javascript, we have DOM methods that have an ability to access the HTML tags. Those methods, such as document.getElementById(), document.getElementByTagName(), etc., make use ... Read More

How to get the length of an object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 15:08:09

2K+ Views

The length property is only applicable to arrays and strings. So when we call the length property on an object we will get undefined.ExampleLive Demo    var object = {prop:1, prop:2};    document.write(object.length); OutputundefinedWhereas arrays and strings will display their length when length property is used on them.ExampleLive Demo    var ... Read More

What is the importance of "enumerable" attribute in defining a property in JavaScript object?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 15:04:55

206 Views

We can define a property of an object using Dot and Bracket notations. There is also another way in which a property called Object.defineProperty() is used to define a property. It usually takes 3 parameters they are object name, property name, property descriptor.syntaxObject.defineProperty(object name, property name, property descriptor)Lets' define a property with this ... Read More

Can re-declaring a variable destroy the value of that variable in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:47:46

214 Views

Re-declaring a variable will not destroy the value of a variable, until and unless it is assigned with some other new value.If we look at the following example variables "x" and ''y'' were assigned with values 4 and 8 respectively, later on when those variables were reassigned, the old values were replaced ... Read More

How to convert a string in to a function in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:57:31

6K+ Views

To convert a string in to function "eval()" method should be used. This method takes a string as a parameter and converts it into a function.syntaxeval(string);ExampleIn the following example, in a string itself, a property called 'age' is assigned with a function. Later on, using eval() function the property age is converted into ... Read More

How to delete a property of an object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:49:20

311 Views

To delete a property of an object, delete key word should be used. Delete key word can be used with both the methods such as Dot method and Bracket method.syntaxdelete object.property;ExampleIn the following example initially when the property "country" is executed its value "England" is displayed in the output. But when that ... Read More

How to convert a string in to date object in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:48:18

232 Views

To convert a string in to date object Date() method should be used. This method creates a date instance that represents a single moment in time in a platform-independent format.ExampleIn the following example a string named "str" is initially parsed using JSON.parse() method and then converted in to date object ... Read More

Advertisements