Vineeth.mariserla has Published 270 Answers

Why it is better not to create numbers as objects in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:42:56

In javascript try not to convert numbers into objects because numbers can't be compared to objects and even objects cannot be compared to objects.ExampleIn the following example, the provided number 20 is assigned to both variable 'x' and variable 'y'. When compared both the variables with each other, Boolean value "true" is displayed as shown ... Read More

How to remove a function from an object in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

JSON.stringify() method not only stringifies an object but also removes any function present in an object. Lets' discuss it in detail.Example-1In the following example, the property 'designation' is a function so when we tried to stringify the object, the function was removed and other properties were displayed as shown in the output.Live Demo<html> <body>   ... Read More

How not to delete a function inside an object when JSON.stringify() method is operated?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:28:14

JSON.stringify() method not only stringifies an object but also removes any function if found inside that object. So to make the function not to be deleted it should be converted into a string and then only JSON.stringify() method should be applied.In the following example since the function is not converted into a string, it is ... Read More

Is it possible to convert a number into other base forms using toString() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:25:10

toString() method is not only used to convert an array into a string but also used to convert a number into other base forms. toString() method can output numbers from base 2 to base 36. Lets' discuss it with an exampleExample-1In the following example, number 46 is converted into various base ... 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

What is the Boolean value of undefined in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:04:03

The Boolean value of undefined is false. The value of Not only undefined but also null, false, NaN, empty string is also false.ExampleIn the following example, boolean values of undefined, false, NaN and empty string were displayed. If we look at the first 3 lines of code a hole is created in the ... Read More

How to create undefined "holes" in an array in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 12:01:31

To create undefined holes try to add elements at higher indexes, leaving smaller indexes untouched. Those leftover smaller indexes will be filled by undefined holes. To understand it in detail lets look at the following example.ExampleIn the following example, only 3 elements were declared. Later on when at index 5, ... 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

Is it possible to make a nested object immutable using Object.freeze() in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:55:59

Object.freeze() method can make an object immutable but in case of a nested object, it can't prevent mutability. Object.freeze() can only provide immutability to the outside parent object, it can't access any inner child(nested) objects.ExampleIn the following example, there are no nested objects. Object.freeze() method will try to freeze the whole object. Therefore there ... Read More

What is the importance of 'for await...of' statement in JavaScript?

vineeth.mariserla

vineeth.mariserla

Updated on 29-Jun-2020 11:52:34

for await...ofThe 'for await...of' statement creates a loop iterating over async objects and sync objects such as arrays, array-like objects, maps sets, etc.syntaxfor await (variable of iterable) {    statement }ExampleIn the following example "for await...of" statement is used to loop over a normal array in an async format and integers were ... Read More

Previous 1 ... 5 6 7 8 9 10 11 ... 27 Next
Advertisements