Vineeth.mariserla has Published 117 Articles

What is the main difference between objects created using object literal and constructor function?

vineeth.mariserla

vineeth.mariserla

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

2K+ Views

Objects created using object literal are singletons, this means when a change is made to the object, it affects the object entire the script. Whereas if an object is created using constructor function and a change is made to it, that change won't affect the object throughout the script. Let's discuss ... Read More

How to prevent modification of object in JavaScript ?.

vineeth.mariserla

vineeth.mariserla

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

272 Views

ECMAScript 5 has introduced several methods to prevent modification of object. Those preventive measures ensures that no one, accidentally or otherwise change functionality of object.There are 3 levels of preventive methods1) Prevent ExtensionsIn this level, one cannot add any new properties or methods but can access existing properties or methods. ... Read More

Explain in detail about Reference-counting garbage collection in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

2K+ Views

 Reference-counting garbage collectionThis is the simplest garbage collection algorithm.This algorithm looks out for those objects which have no references   left.An object becomes eligible for garbage collection if it has no references attached to it.The garbage collection is   explained in the below example.Examplevar obj = {       ... Read More

How to sort an array in JavaScript?Explain with example?

vineeth.mariserla

vineeth.mariserla

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

89 Views

SortingSorting is nothing but displaying elements in ascending or descending order. Array.sort() function is to sort the array according to the compare() function in JavaScript.a) In the given program we are going to sort the array by  age property in descending order. Live DemoExample    var persons = [ ... Read More

How to pass arrays as function arguments in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

3K+ Views

Passing arrays as function argumentsIn olden days if we need to pass arrays as function arguments then apply() and null should be used. The use of null makes a code unclean. So to make code clean and also to pass an array as a function argument, the spread operator comes in to ... Read More

How can closures cause memory leak and how to prevent it?

vineeth.mariserla

vineeth.mariserla

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

1K+ Views

ClosureOne of the strengths of javascript is closures. Javascript allows nested functions, a function inside a function, to access the variables of parent functions. This process of accessing outer function's variable by an inner function is called a closure. A memory leak occurs when a declared variable is automatically available ... Read More

How can circular references cause memory leakage in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

381 Views

Circular reference A circular reference is formed when two variables reference to each other there by giving each object a reference count of 1.In pure garbage collected system, a circular reference may not be a problem when the variables involved were have no references.In that scenario the declared variables will be ... Read More

what are the differences between unshift() and push() methods in javascript?

vineeth.mariserla

vineeth.mariserla

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

1K+ Views

Both the methods are used to  add elements to the array.But the only difference is unshift() method adds the element at the start of the array whereas push() adds the element at the end of the array.1) push()Array.push() method is used to add an element at the end of an ... Read More

How to find the maximum value of an array in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

1K+ Views

we can find the Maximum value of an array using Math.max() and sort() functions.1) Math.max()Math.max() function usually takes all the elements in an array and scrutinize each and every value to get the maximum value.It's methodology is discussed in the below example. Live DemoExample    function maximum(value) { ... Read More

How to find the minimum value of an array in JavaScript?

vineeth.mariserla

vineeth.mariserla

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

3K+ Views

We can find the minimum value of an array using Math.min() and sort()1) Math.min() Math.min() function usually takes all the elements in an array and scrutinize each and every value to get the minimum value.It's methodology is discussed in the below example. Live DemoExample    function minimum(value) {     ... Read More

Advertisements