Vineeth.mariserla has Published 140 Articles

How to swap variables with destructuring in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

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

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

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

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

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

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

What is the use of apply() function in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:08:54

Traditionally we have objects which have their own unique methods and properties. Using apply() function we can construct a method that can access all the given objects combined.Actually, this method works the same as call() function but when there is a need to pass an array like variables, apply() function comes into ... 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

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

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

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