Javascript – Common methods for Build-in classes

Date

Array

You can also define an array

var a = new Array();

or with initial values:

var a = new Array(11, 22, 33, 44);

if you put only one argument then you specify the length of the array:

  • push(element) – add a new array element at the end
  • pop() – deletes the last element
  • join(char) – joins all the elements of an array with the character you specify and return it as a string
  • splice(start, end) – removes elements
  • splice(start, howMany to removed, newElement, newElement…) – you can replace elements or just add new elements
add new elements
replaces 3 elements

Math

All Math methods are static, that means that you do not need to create an object to use them.

Get a random number between 0 and 5

5* Math.random();

get a random between min and max number

((max - min) * Math.random()) + min;

Number

String

Javascript – Common methods for Build-in classes

Read More

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s