
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

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) { if (toString.call(value) !== "[object Array]") return false; return Math.min.apply(null, value); } document.write(minimum([6, 39, 55, 1, 44])); Output12) sort()Using sort() and compare functions we can write the elements in ascending or descending order, later on using length property we can ... Read More

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) { if (toString.call(value) !== "[object Array]") return false; return Math.max.apply(null, value); } document.write(maximum([6, 39, 55, 1, 44])); Output55.2) sort()Using sort and compare functions we can ... Read More

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 array like a queue .In the following example it is shown how to add an element using push() method Live DemoExample var cars = ["Benz", "Lamborghini", "Tata safari"]; cars.push("Ferrari"); document.write(cars); OutputBenz, Lamborghini, Tata safari, Ferrari2) unshift()Array.unshift() method is ... Read More

185 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 = [ { name: 'rajesh', birthdate: 1845, death: 1875 }, { name: 'Bharat', birthdate: 1909, death: 1917}, { name: ... Read More

2K+ Views
Reversing an array means that we are reversing the order of elements present in the array, but not the array itself. In simpler terms, the element at 0th index will be shifted to the last index of the array and vice versa. There are various ways to reverse an array in JavaScript in this article, we will look into these in detail − Using the reverse() method() The reverse() method in JavaScript reverses the order of the array elements. The first element in the array is swapped with the last element, the second element is swapped with the second last ... Read More

1K+ Views
To find the cubes of elements of given array we need to run a for loop to access each and every element and we need to use "=" operator to replace elements with their cubes.To get the desired values the below steps need to be followed.Steps1) Declared an array a = [1, 2, 3, 4, 5]2) For loop was introduced to access each and every element in the array(a[i]).3) Inside for loop "=" operator is used to replace the element with their cubic values(a[i]*a[i]*a[i]).so, from the above steps the output obtained will be 1, 8, 27, 64, 125.By following the ... Read More

204 Views
JavaScript Bitwise NOT Live DemoExample document.getElementById("not").innerHTML = ~ 13; Output-14Explanation: It gives 0 for 1 and 1 for 0.The above result is 14.JavaScript Bitwise leftshift operator Live DemoExample document.getElementById("left").innerHTML = 5

1K+ Views
Html taga) The tag is used to define a client-side script.b) The tag contains scripting statements or an external script file.JavaScript code must be keep in script tag.Let's see the use of the tag. For suppose declare the variable outside the script tag. Live DemoExample var a = 1; var b = 2; var c = a + b; document.getElementById("tag").innerHTML = c; Outputvar a = 1For suppose, let the variable be declared inside the script tag. Live DemoExample var a = 1; var b = 2; var c = a + b; document.getElementById("tag").innerHTML = c; Output3

214 Views
JavaScript TagsThe html script tag wants the browser to get a script between them. We can expect the scripts to be in the following places. 1.The script can be placed in html's head tag 2.Within Html's body tag. 3.As an external file. Most importantly client side scripts such as JavaScript are placed in script tags.demonstration code Live Demo This example writes "JavaScript is not java" into an HTML element with id="script" document.getElementById("imp").innerHTML = "JavaScript is not java"; OutputThis example writes "JavaScript is not java" into an HTML element with id="script" JavaScript is not javaExplanationEvery JavaScript code should be in ... Read More

2K+ Views
There are 4 ways to display the output in JavaScript. a) Displaying the output in HTML elements, using innerHTML attribute. Live DemoExample document.getElementById("display").innerHTML = 10 + 10; Output20.b) Displaying the output using document.write(). Live DemoExample document.write(2 + 3); Output5c) Displaying the output through console.log(). Live DemoExample console.log(2 + 3); In debugger console, the output5.d) Displaying the output through alert box. Live DemoExample alert(2 + 3); In alert window box, the output5In case of handling json strings, or some other big data console.log is the best choice.