Category JavaScript

JavaScript Array Search

JavaScript Array indexOf() The indexOf() method searches an array for an element value and returns its position. Note: The first item has position 0, the second item has position 1, and so on. Example Search an array for the item…

JavaScript Array Methods

JavaScript Array length The length property returns the length (size) of an array: Example const fruits = [“Banana”, “Orange”, “Apple”, “Mango”]; let size = fruits.length; JavaScript Array toString() The JavaScript method toString() converts an array to a string of (comma…

JavaScript Arrays

An array is a special variable, which can hold more than one value: const cars = [“Saab”, “Volvo”, “BMW”]; Why Use Arrays? If you have a list of items (a list of car names, for example), storing the cars in…

JavaScript Number Properties

Property Description EPSILON The difference between 1 and the smallest number > 1. MAX_VALUE The largest number possible in JavaScript MIN_VALUE The smallest number possible in JavaScript MAX_SAFE_INTEGER The maximum safe integer (253 – 1) MIN_SAFE_INTEGER The minimum safe integer…

JavaScript Number Methods

JavaScript Number Methods These number methods can be used on all JavaScript numbers: Method Description toString() Returns a number as a string toExponential() Returns a number written in exponential notation toFixed() Returns a number written with a number of decimals…

JavaScript BigInt

JavaScript BigInt variables are used to store big integer values that are too big to be represented by a normal JavaScript Number. JavaScript Integer Accuracy JavaScript integers are only accurate up to 15 digits: Integer Precision let x = 999999999999999;…

JavaScript Numbers

JavaScript has only one type of number. Numbers can be written with or without decimals. Example let x = 3.14;    // A number with decimals let y = 3;       // A number without decimals   Extra large or extra small…

JavaScript Template Strings

Back-Tics Syntax Template Strings use back-ticks (“) rather than the quotes (“”) to define a string: Example let text = `Hello World!`; Quotes Inside Strings Template Strings allow both single and double quotes inside a stringn :

JavaScript String Search

JavaScript String indexOf() The indexOf() method returns the index (position) of the first occurrence of a string in a string, or it returns -1 if the string is not found: Example let text = “Please locate where ‘locate’ occurs!”; let…