Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




valueOf() - FUNCTION


valueOf() Function


The valueOf() Function is used to return the Array as is.


Let us say we have the below array with four elements.


var x = [5, 8, 2, 9]
JavaScript valueOf()-Function


Example :



<html>
<body>  
<script>

	var x = [5, 8, 2, 9]
	var y = x.valueOf()
	document.write(y)
	    
</script>      
</body>
</html>


Output :



  5,8,2,9

So, in the above code we have array that has 4 numbers.


var x = [5, 8, 2, 9]
JavaScript valueOf()-Function


And we want to display the values of the Arrays as is.


So we have used the valueOf() function to display the array as is.


var y = x.valueOf()