
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 6710 Articles for Javascript

1K+ Views
In JavaScript finally is a block of code or statements that are executed in all cases while handling errors with a try and catch block whenever used. These try, catch and finally blocks in JavaScript will execute the code that is prone to error and may cause the program to behave incorrectly (terminate abruptly). This finally block is positioned after the try and catch blocks, will unquestionably be executed if either of those blocks, try or catch, is ever executed. The finally block allows us to define the actions that must be performed regardless of whether some code succeeds or ... Read More

252 Views
The use of "=" operator is that it assigns value from right to left, whereas "==" shows whether the given values are equal or not.In the following example variables x and y were assigned values using "=" operator and their magnitudes were checked using "==" operator.Example Live Demo var x = 5; var y = "6"; document.write(x); document.getElementById("equal").innerHTML = (x == y); Outputfalse 5

184 Views
The difference between '==' and '===' is that former checks only value but the latter checks value and also data type(String, Boolean etc).The following example gives whether values assigned are equal or not irrespective of datatype. a) "==" operator(checks equality) Example Live Demo var x = 5; var y = 5; var z = 6; document.getElementById("strict").innerHTML = (x == y) + "" + (x == z); Outputtrue falseb) '===' operator (Checks strict equality) "===" operator gives true if and only if both value and data type are equal.If not it returns false.In ... Read More

1K+ Views
Array is an object which contains multiple values of the same datatype in a sequential order. In other words, we can say that an array is a special type of object in the JavaScript. SyntaxWe can create an array in two ways in JavaScript. The syntax are given below − var arr = [val1, val2, …]; var arr = new Array(“val1”, “val2”, …) Now let us look at a simple JavaScript program to create an array and print its index values − var arr = [1, 2, 3, 4, 5]; document.write(arr[0]); Here, the program returns the content in ... Read More

74 Views
The toString() function of the TypedArray object returns a string representing the contents of the typed array.SyntaxIts Syntax is as followstypedArray.toString();Example Live Demo JavaScript Example var typedArray = new Int32Array([111, 56, 62, 40, 75, 36, 617, 2, 139, 827 ]); var result = typedArray.toString(); document.write("Contents of the typed array: "+result); OutputContents of the typed array: 111,56,62,40,75,36,617,2,139,827

78 Views
The subarray() function of the TypedArray object returns portion of the current array. It accepts two numbers representing the start and end of the sub array.SyntaxIts Syntax is as followstypedArray.subarray(5, 9)Example Live Demo JavaScript Example var typedArray = new Int32Array([111, 56, 62, 40, 75, 36, 617, 2, 139, 827 ]); var result = typedArray.subarray(3, 7); document.write("Contents of the typed array: "+result); OutputContents of the typed array: 40,75,36,617

85 Views
The values() function of the TypedArray returns an iterator object which holds the values of the typed array. The next() method returns the next element in the iterator object.SyntaxIts Syntax is as followstypedArray.values()Example Live Demo JavaScript Example var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); var iterator = typedArray.values(); document.write("Contents of the typed array: "); for(i=0; i

122 Views
The sort() method of the Typed Array object arranges the elements of the array in ascending order and returns it.SyntaxIts Syntax is as followsarrayBuffer.sort()Example Live Demo JavaScript Array every Method var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); document.write("Contents of the typed array: "+typedArray); document.write(""); var resultantArray = typedArray.sort(); document.write("Resultant Array: "+resultantArray); OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 Resultant Array: 2,3,4,5,8,11,13,15,17,19

92 Views
The slice() method of the typed array object returns a portion or, chunk from the array buffer (as a separate object). It accepts two integer arguments representing the start and end of the portion of the array to be returned.SyntaxIts Syntax is as followsarrayBuffer.slice(3, 8)Example Live Demo JavaScript Array every Method var typedArray = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); document.write("Contents of the typed array: "+typedArray); document.write(""); var resultantArray = typedArray.slice(2, 7); document.write("Resultant Array: "+resultantArray); OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 ResultantArray: 13,4,15,3,1

47 Views
The set() function of TypedArray object accepts an array a number representing the index and copies the contents of the specified array in to the current array starting at the given index.SyntaxIts Syntax is as followstypedArray.set()Example Live Demo JavaScript Array every Method var typedArray1 = new Int32Array([11, 5, 13, 4, 15, 3, 17, 2, 19, 8 ]); document.write("Contents of the typed array: "+typedArray1); document.write(""); var typedArray2 = new Int32Array([110, 215, 316, 916, 616, 117, 311 ]); typedArray1.set(typedArray2, 3); document.write("Result: "+typedArray1); OutputContents of the typed array: 11,5,13,4,15,3,17,2,19,8 Result: 11,5,13,110,215,316,916,616,117,311