-
Resumo:
- Javascript is a dynamically typed language, meaning that it's engine figures out the value of a variable at run time. This allows variables to change such as from a number to a char.
- Functions can be global (where it's results will be available to the entire page) or locally.
Locally: when you create a variable inside a function, it only exists there. - Used to build other data structures.
- JS has 7 built-in types: 6 primitive and 1 Object type.
- Object type: a collection of name/value pairs. Ex: firstName: Noah (firstName is the name and Noah is the value being atributed to that name).
- Primitive type: represents a single, immutable value:
Single value, therefore, not an object.
Immutable means once it's set, it can not be changed.
 * Value becomes read only.
 * You can create another value based on an existing one. - Usually you put .js files that require the whole content of the page to be loaded first on the bottom
of the codding.
Assim, quando chamar o elemento, por exemplo console.log('title'), para mostrar o title da pagina, ja vai ter sido carregado, being that if the script was at the top, it wouldn't know the title. - JavaScript is:
a) Lightweight: doesn't consume much memory of the computer and it has a simple syntax and features.
b) Crossplaform: means that the language can be used on multiple plataforms and systems, not only for webdevelopment.
c) Object-oriented: it's a language based on objects. -
Today, JavaScript can be used in different places:
Client-side: JavaScript was traditionally only used in the browser.
Server-side: Thanks to node.js, we can use JavaScript on the server as well. -
Made modern development possible:
a) Dynamic effects interactivity (adicionar efeitos a simples websites).
b) Modern web applications that we can interact with. -
Data Types
a) Numbers: float, int (but here all numbers are treated as float).
b) String: text.
c) Boolean: true, false.
d) Undefined: variable declared on the script but no value was attributed to it.
Example: var job;
e) Null: variable defined but empty, no values in it. -
Code
\b - backspace
\f - form feed
\n - new line
\r - carriage return
\t - Tabulação horizontal
\v - tabulação vertical
\' - aspas simples
\" - aspas duplas
\\ - barra invertida
\XXX - caractere no formato Latin-1 (XXX é um valor octal entre 0 e 377)
\xXX - caractere no formato Latin-1 (XX é um valor hexadecimal entre 00 e FF)
\uXXXX - caractere no formato Unicode, especificado por um valor hexadecimal de 4 dígitos. O navegador deve suportar Unicode e o sist.op. deve ter as fontes instaladas para que os caracteres sejam visualizados.
Types
What is JavaScript ?