JavaScript/Funções e objetos predefinidos
| Este módulo tem a seguinte tarefa pendente: Completar a lista (faltam objetos...) |
Existem uma série de objetos que já estão definidos para o desenvolvedor, este objetos são largamente utilizados na linguagem, e são fundamentais para interação com os sistemas.
Funções predefinidas segundo o padrão ECMA 262
[editar | editar código]Versão consultada: 5.1 .
- Array.prototype.concat
- Array.prototype.constructor
- Array.prototype.every
- Array.prototype.filter
- Array.prototype.forEach
- Array.prototype.indexOf
- Array.prototype.join
- Array.prototype.lastIndexOf
- Array.prototype.map
- Array.prototype.pop
- Array.prototype.push
- Array.prototype.reduce
- Array.prototype.reduceRight
- Array.prototype.reverse
- Array.prototype.shift
- Array.prototype.slice
- Array.prototype.some
- Array.prototype.sort
- Array.prototype.splice
- Array.prototype.toLocaleString
- Array.prototype.toString
- Array.prototype.unshift
- Boolean.prototype.constructor
- Boolean.prototype.toString
- Boolean.prototype.valueOf
- Date.prototype.constructor
- Date.prototype.getDate
- Date.prototype.getDay
- Date.prototype.getFullYear
- Date.prototype.getHours
- Date.prototype.getMilliseconds
- Date.prototype.getMinutes
- Date.prototype.getMonth
- Date.prototype.getSeconds
- Date.prototype.getTime
- Date.prototype.getTimezoneOffset
- Date.prototype.getUTCDate
- Date.prototype.getUTCDay
- Date.prototype.getUTCFullYear
- Date.prototype.getUTCHours
- Date.prototype.getUTCMilliseconds
- Date.prototype.getUTCMinutes
- Date.prototype.getUTCMonth
- Date.prototype.getUTCSeconds
- Date.prototype.getYear
- Date.prototype.setDate
- Date.prototype.setFullYear
- Date.prototype.setHours
- Date.prototype.setMilliseconds
- Date.prototype.setMinutes
- Date.prototype.setMonth
- Date.prototype.setSeconds
- Date.prototype.setTime
- Date.prototype.setUTCDate
- Date.prototype.setUTCFullYear
- Date.prototype.setUTCHours
- Date.prototype.setUTCMilliseconds
- Date.prototype.setUTCMinutes
- Date.prototype.setUTCMonth
- Date.prototype.setUTCSeconds
- Date.prototype.setYear
- Date.prototype.toDateString
- Date.prototype.toGMTString
- Date.prototype.toISOString
- Date.prototype.toJSON
- Date.prototype.toLocaleDateString
- Date.prototype.toLocaleString
- Date.prototype.toLocaleTimeString
- Date.prototype.toString
- Date.prototype.toTimeString
- Date.prototype.toUTCString
- Date.prototype.valueOf
- Error.prototype.constructor
- Error.prototype.message
- Error.prototype.name
- Error.prototype.toString
- Function.prototype.apply
- Function.prototype.bind
- Function.prototype.call
- Function.prototype.constructor
- Function.prototype.toString
- NativeError.prototype.constructor
- NativeError.prototype.message
- NativeError.prototype.name
- Number.prototype.constructor
- Number.prototype.toExponential
- Number.prototype.toFixed
- Number.prototype.toLocaleString
- Number.prototype.toPrecision
- Number.prototype.toString
- Number.prototype.valueOf
- Object.prototype.constructor
- Object.prototype.hasOwnProperty
- Object.prototype.isPrototypeOf
- Object.prototype.propertyIsEnumerable
- Object.prototype.toLocaleString
- Object.prototype.toString
- Object.prototype.valueOf
- RegExp.prototype.constructor
- RegExp.prototype.exec
- RegExp.prototype.test
- RegExp.prototype.toString
- String.prototype.charAt
- String.prototype.charCodeAt
- String.prototype.concat
- String.prototype.constructor
- String.prototype.indexOf
- String.prototype.lastIndexOf
- String.prototype.localeCompare
- String.prototype.match
- String.prototype.replace
- String.prototype.search
- String.prototype.slice
- String.prototype.split
- String.prototype.substr
- String.prototype.substring
- String.prototype.toLocaleLowerCase
- String.prototype.toLocaleUpperCase
- String.prototype.toLowerCase
- String.prototype.toString
- String.prototype.toUpperCase
- String.prototype.trim
- String.prototype.valueOf
- (Objeto global) eval (x)
- (Objeto global) parseInt (string , radix)
- (Objeto global) parseFloat (string)
- (Objeto global) isNaN (number)
- (Objeto global) isFinite (number)
Matemática
[editar | editar código]Atributos
| Nome | Descrição |
|---|---|
| E | valor da constante e (2.718281828459045) |
| LN10 | logarítimo natural de 10 (2.302585092994046) |
| LN2 | logarítimo natural de 2 (0.6931471805599453) |
| LOG2E | logarítimo de e na base 2 (1.4426950408889634) |
| LOG10E | logarítimo de e na base 10(0.4342944819032518) |
| PI | valor do pi (3.141592653589793) |
| SQRT1_2 | raiz quadrada de 1/2 (0.7071067811865476) |
| SQRT2 | raiz quadrada de 2(1.4142135623730951) |
Métodos
| Nome | Descrição |
|---|---|
| abs(v) | valor absoluto de v |
| acos(v) | arcocosseno de v |
| asin(v) | arcoseno de v |
| atan(v) | arcotangente de v |
| atan2(y, x) | arcotangente de y/x |
| ceil(v) | próximo valor inteiro superior a v |
| cos(v) | cosseno de v |
| exp(v) | e elevado a v |
| floor(v) | próximo valor inteiro inferior a v |
| log(v) | logarítimo de v na base 10 |
| max(valor ...) | maior valor da lista |
| min(valor ...) | menor valor da lista |
| pow(x, y) | x elevado a y |
| ramdom() | numero randomico de >= 0 e < 1 |
| round(v) | arredondamento de v |
| sin(v) | seno de v |
| sqrt(v) | raiz quadrada de v |
| tan(v) | tangente de v |
Data e hora
[editar | editar código]| Nome | Descrição |
|---|---|
|
Construtor: Date(ano, mês) Date(ano, mês, dia) Date(ano, mês, dia, hora) Date(ano, mês, dia, hora, minuto) Date(ano, mês, dia, hora, minuto, segundos) Date(ano, mês, dia, hora, minuto, segundos, milesegundos) |
Todos os parâmetros são opcionais. Lembre-se apenas que o mês janeiro é representado por 0 e não por 1. |
|
Date.UTC(ano, mês) Date.UTC(ano, mês, dia) Date.UTC(ano, mês, dia, hora) Date.UTC(ano, mês, dia, hora, minuto) Date.UTC(ano, mês, dia, hora, minuto, segundos) Date.UTC(ano, mês, dia, hora, minuto, segundos, milesegundos) |
Cria tempo relativo ao UTC. Da mesma forma que o contrutor |
|
Date.parse(texto) |
Converte a data para um objeto date, o formato é o mesmo utilizado no toString() |
|
Date.now() |
Retorna um objeto date representando o momento, o mesmo que new Date(), porém retorna não um objeto, porém um número. |
|
getDate() |
Retorna o dia |
|
getDay() |
Retorna o dia da semana |
|
getFullYear() |
Retorna um inteiro com o valor do ano |
|
getHours() |
Retorna hora |
|
getMilliseconds() |
Retorna os milisegundos |
|
getMinutes() |
Retorna os minutos |
|
getMonth() |
Retorna o mês, janeiro = 0 |
|
getSeconds() |
Retorna os segundos |
|
getTime() |
Numero de milisegundos representando a data |
|
getTimezoneOffset() |
Retorna a diferença em minutos do horario local e o UTC |
|
getUTCDate() |
Retorna o dia UTC |
|
getUTCDay() |
Retorna o dia da semana UTC |
|
getUTCFullYear() |
Retorna o ano UTC |
|
getUTCHours() |
Retorna a hora UTC |
|
getUTCMilliseconds() |
Milissegundos UTC |
|
getUTCMinutes() |
Retorna os minutos UTC |
|
getUTCMonth() |
Retorna o mês UTC |
|
getUTCSeconds() |
Retorna os segundos |
|
getYear() |
Retorna o ano menos 1900, ex/2004 retorna 104, pois 2004 = 104 + 1900 |
|
objDate.setMinutes(minutos) objDate.setMinutes(minutos, segundo) setMinutes(minutos, segundo, milessegundo) |
Atribui minutos |
|
objDate.setUTCHours(hora, minuto, segundo, milesegundo) |
Atribui hora UTC |
|
setDate(dia) |
Atribui dia do mês |
|
setFullYear(ano) setFullYear(ano, mês) setFullYear(ano, mês, dia) |
Atribui ano |
|
setHours(hora) setHours(hora, minuto) setHours(hora, minuto, segundo) setHours(hora, minuto, segundo, milesegundo) |
Atribui hora |
|
setMilliseconds(milisegundos) |
Atribui milisegundos |
|
setMonth(mes) setMonth(mes, dia) |
Atribui mês |
|
setSeconds(segundos) setSeconds(segundos, milesegundo) |
Atribui segundos |
|
setTime(milisegundos) |
Milisegundos da data |
|
setUTCDate(dia) |
Atribui dia do mês UTC |
|
setUTCFullYear(ano) setUTCFullYear(ano, mês) setUTCFullYear(ano, mês, dia) |
Atribui ano UTC |
setUTCMilliseconds(milisegundos) |
Atribui milisegundos UTC |
|
setUTCMinutes(minutos) setUTCMinutes(minutos, segundo) setUTCMinutes(minutos, segundo, milisegundo) |
Atribui minutos UTC |
|
setUTCMonth(mes) setUTCMonth(mes, dia) |
Atribui mês UTC |
|
setUTCSeconds(segundos) setUTCSeconds(segundos, milesegundo) |
Atribui segundos UTC |
|
setYear(ano) setYear(ano, mês) setYear(ano, mês, dia) |
Atribui ano, numero que menos 1900 do ano atual |
|
toLocaleDateString() |
Converte para string apenas a parte da data |
|
toLocaleTimeString() |
Converte para string apenas a parte da hora |
|
toUTCString() |
Converte para string UTC |