Vineeth.mariserla has Published 117 Articles

What is the difference between Map and WeakMap in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

4K+ Views

Differences between Map and WeakMapThe functional mechanism of Map and WeakMap is same but they have little differences.1) A WeakMap accepts only objects as keys whereas a Map, in addition to objects, accepts primitive datatype such as strings, numbers etc.2) WeakMap objects doesn't avert garbage collection if there are no ... Read More

What is an object in JavaScript and access any property ?**

vineeth.mariserla

vineeth.mariserla

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

71 Views

Accessing Property Of An ObjectWithout objects there is no JavaScript. Everything such as boolean, numbers, functions etc are all objects.Accessing properties of an object is explained in the following method.Example-1 Live Demo    myObj = {"name":"Ramesh", "age":30, "family":            [{"mother":"Geetha", "father":"Rao"}], "city":"Berlin"};       ... Read More

What is non-enumerable property in JavaScript and how can it be created?

vineeth.mariserla

vineeth.mariserla

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

2K+ Views

Non-enumerable propertyObjects can have properties that don't show up when iterated through the particular object using Object.keys() or for...in loop.Those type of properties are called as non-enumerable properties.Creating a non-enumerable propertyTo create a non-enumerable property we have to use Object.defineProperty() method. This a special method to create non-enumerable properties in ... Read More

What is JSON.stringify() and explain its use in javascript?

vineeth.mariserla

vineeth.mariserla

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

150 Views

JSON.stringify()If we need to send data to a web server the data should be a string.To change the object literal to string JSON.stringify() method should be used.For instanceExample-1 Live Demo var obj = {name:"rekha", age:40, city:"newyork"}; var myJSON = JSON.stringify(obj); ... Read More

How to merge properties of two JavaScript Objects dynamically?

vineeth.mariserla

vineeth.mariserla

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

225 Views

There are two methods to merge properties of javascript objects dynamically. They are1) Object.assign() The Object.assign() method is used to copy the values of all properties from one or more source objects to a target object. It will return the target object.Example-1 Live Demo var target = ... Read More

What is JSON.parse() and and explain its use in javascript?

vineeth.mariserla

vineeth.mariserla

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

128 Views

JSON.parse()When the data is received from web server, the data is always a string .So to change it to the object, JSON.parse() method is used. Example Live Demo    var obj = '{"name":"Jon", "age":20, "city":"Columbia"}';    var res = JSON.parse(obj);    document.write(res);   console.log(res); output[object object] {"name":"Jon", ... Read More

How to remove html tags from a string in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

7K+ Views

Removing HTML tags from a stringWe can remove HTML/XML tags in a string using regular expressions in javascript. HTML elements such as span, div etc. are present between left and right arrows for instance , etc. So replacing the content within the arrows, along with the arrows, with nothing('') can ... Read More

Describe pass by value and pass by reference in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

1K+ Views

Pass by value In pass by value, a function is called by directly passing the value of the variable as the argument. Changing the argument inside the function doesn’t affect the variable passed from outside the function. Javascript always pass by value so changing the value of the variable never changes the ... Read More

What is the importance of Math.trunc() method in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

105 Views

Math.trunc()Unlike Math.floor(), Math.ceil() and Math.round(), Math.trunc() method removes fractional part and gives out only integer part. It doesn't care about rounding the number to the nearest integer. It doesn't even notice whether the value is positive or negative. Its function is only to chop up the fractional part.syntaxMath.trunc(x);parameters - Math.trunc() takes a number as an ... Read More

Explain Generator functions in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

499 Views

GeneratorsJavaScript supports Generator functions and Generator Objects. A generator function is the same as a normal function, but whenever it needs to generate a value it uses the 'yield' keyword rather than 'return'. The 'yield' keyword halts the function execution and sends a value back to the caller. It has ... Read More

Advertisements