Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

JavaScript Properties

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

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 -(253 - 1)
POSITIVE_INFINITY Infinity (returned on overflow)
NEGATIVE_INFINITY Negative infinity (returned on overflow)
NaN A "Not-a-Number" value

JavaScript Strings
A JavaScript string stores a series of characters like "Dani Liam".

A string can be any text inside double or single quotes:

let carName1 = "BMW XC60";


let carName2 = 'BMW XC60';

String indexes are zero-based:

The first character is in position 0, the second in 1, and so on.

For a tutorial about Strings, read our JavaScript String Tutorial.

String Properties and Methods


Normally, strings like "Dani Liam", cannot have methods or properties because they are
not objects.

But with JavaScript, methods and properties are also available to strings, because
JavaScript treats strings as objects when executing methods and properties.
JavaScript String Methods:
Method Description

concat() Merge two or more arrays, and returns a new array.

copyWithin() Copies part of an array to another location in the same array and returns it.

entries() Returns a key/value pair Array Iteration Object.

every() Checks if every element in an array pass a test in a testing function.

fill() Fill the elements in an array with a static value.

filter() Creates a new array with all elements that pass the test in a testing function.

find() Returns the value of the first element in an array that pass the test in a testing function.

findIndex() Returns the index of the first element in an array that pass the test in a testing function.

forEach() Calls a function once for each array element.

from() Creates an array from an object.

includes() Determines whether an array includes a certain element.

indexOf() Search the array for an element and returns its first index.

isArray() Determines whether the passed value is an array.

join() Joins all elements of an array into a string.

keys() Returns a Array Iteration Object, containing the keys of the original array.
lastIndexOf() Search the array for an element, starting at the end, and returns its last index.

map() Creates a new array with the results of calling a function for each array element.

pop() Removes the last element from an array, and returns that element.

push() Adds one or more elements to the end of an array, and returns the array's new length.

reduce() Reduce the values of an array to a single value (from left-to-right).

reduceRight() Reduce the values of an array to a single value (from right-to-left).

reverse() Reverses the order of the elements in an array.

shift() Removes the first element from an array, and returns that element.

slice() Selects a part of an array, and returns the new array.

some() Checks if any of the elements in an array passes the test in a testing function.

sort() Sorts the elements of an array.

splice() Adds/Removes elements from an array.

toString() Converts an array to a string, and returns the result.

unshift() Adds new elements to the beginning of an array, and returns the array's new length.

values() Returns a Array Iteration Object, containing the values of the original array.

Method Description
JavaScript | Object Properties
Object properties are defined as a simple association between name and value. All
properties have a name and value is one of the attributes linked with the property, which
defines the access granted to the property. Properties refer to the collection of values
which are associated with the JavaScript object. This collection may not follow any
particular order. JavaScript provides the feature to add, delete and modify the
properties. Properties are denoted by name:values pairs.

 objectName.property
 objectName["property"]
 objectName[expression]

The JavaScript Array Object


The JavaScript Array object is a global object that is used in the construction of arrays.
An array is a special type of variable that allows you to store multiple values in a single
variable.
To learn more about Arrays, please check out the JavaScript array chapter.

Array Properties
Property Description

length Sets or returns the number of elements in an array.


prototype Allows you to add new properties and methods to an Array object.

Array Methods
Method Description

concat() Merge two or more arrays, and returns a new array.


copyWithin() Copies part of an array to another location in the same array and returns
it.
entries() Returns a key/value pair Array Iteration Object.
every() Checks if every element in an array pass a test in a testing function.
fill() Fill the elements in an array with a static value.
filter() Creates a new array with all elements that pass the test in a testing
function.
find() Returns the value of the first element in an array that pass the test in a
testing function.
findIndex() Returns the index of the first element in an array that pass the test in a
testing function.
forEach() Calls a function once for each array element.
from() Creates an array from an object.
includes() Determines whether an array includes a certain element.
indexOf() Search the array for an element and returns its first index.
isArray() Determines whether the passed value is an array.
join() Joins all elements of an array into a string.
keys() Returns a Array Iteration Object, containing the keys of the original array.
lastIndexOf() Search the array for an element, starting at the end, and returns its last
index.
map() Creates a new array with the results of calling a function for each array
element.
pop() Removes the last element from an array, and returns that element.
push() Adds one or more elements to the end of an array, and returns the
array's new length.
reduce() Reduce the values of an array to a single value (from left-to-right).
reduceRight() Reduce the values of an array to a single value (from right-to-left).
reverse() Reverses the order of the elements in an array.
shift() Removes the first element from an array, and returns that element.
slice() Selects a part of an array, and returns the new array.
some() Checks if any of the elements in an array passes the test in a testing
function.
sort() Sorts the elements of an array.
splice() Adds/Removes elements from an array.
toString() Converts an array to a string, and returns the result.
unshift() Adds new elements to the beginning of an array, and returns the array's
new length.
values() Returns a Array Iteration Object, containing the values of the original
array.

You might also like