Javascript – Common methods for Build-in classes

Date

, <span>Javascript – Common methods for Build-in classes</span>, KandZ
, <span>Javascript – Common methods for Build-in classes</span>, KandZ

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:

, <span>Javascript – Common methods for Build-in classes</span>, KandZ
, <span>Javascript – Common methods for Build-in classes</span>, KandZ
  • 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
, <span>Javascript – Common methods for Build-in classes</span>, KandZ
add new elements
, <span>Javascript – Common methods for Build-in classes</span>, KandZ
, <span>Javascript – Common methods for Build-in classes</span>, KandZ
replaces 3 elements
, <span>Javascript – Common methods for Build-in classes</span>, KandZ

Math

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

, <span>Javascript – Common methods for Build-in classes</span>, KandZ
, <span>Javascript – Common methods for Build-in classes</span>, KandZ

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

, <span>Javascript – Common methods for Build-in classes</span>, KandZ
, <span>Javascript – Common methods for Build-in classes</span>, KandZ

String

, <span>Javascript – Common methods for Build-in classes</span>, KandZ
, <span>Javascript – Common methods for Build-in classes</span>, KandZ
105490cookie-checkJavascript – Common methods for Build-in classesJavascript – Common methods for Build-in classes

Related posts

One Thought to “Javascript – Common methods for Build-in classes

  1. […] Javascript – Common methods for Build-in classes […]

Comments are closed.