Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Traducción del apartado Introducción de la Parte 1#4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
victorze wants to merge3 commits intojavascript-tutorial:getting-startedfromunknown repository
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 66 additions & 66 deletions1-js/01-getting-started/1-intro/article.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,120 @@
#An Introduction to JavaScript
#Una introducción a JavaScript

Let's see what's so special aboutJavaScript,what we can achieve with it, and which other technologies play well with it.
Veamos qué tiene de especialJavaScript,qué podemos lograr con él y qué otras tecnologías juegan bien con él.

##What is JavaScript?
##¿Qué es JavaScript?

*JavaScript*was initially created to *"make web pages alive"*.
*JavaScript*fue creado inicialmente para *"dar vida a las paginas web"*.

The programs in this language are called *scripts*.They can be written right in awebpage's HTML and executed automatically as the page loads.
Los programas en este lenguaje se llaman *scripts*.Se pueden escribir directamente en el HTML de una páginaweby ejecutarse automáticamente a medida que se carga la página.

Scripts are provided and executed as plain text. They don't need special preparation or compilation to run.
Los scripts se proveen y ejecutan como texto plano. No necesitan una preparación especial o compilación para su ejecución.

In this aspect, JavaScriptis very different from another language called [Java](https://en.wikipedia.org/wiki/Java_(programming_language)).
En este aspecto, JavaScriptes muy diferente de otro lenguaje llamado [Java](https://es.wikipedia.org/wiki/Java_(lenguaje_de_programación)).

```smart header="Why <u>Java</u>Script?"
When JavaScript was created, it initially had another name: "LiveScript".But Javawas very popularat that time, so it was decided that positioning a new language as a "younger brother" of Javawould help.
```smart header="¿Por qué <u>Java</u>Script?"
Cuando se creó JavaScript, inicialmente tenía otro nombre: "LiveScript".Pero Javaera muy popularen ese momento, por lo que se decidió que posicionar un nuevo lenguaje como un "hermano menor" de Javaayudaría.

But as it evolved, JavaScriptbecame a fully independent language with its own specification called[ECMAScript](http://en.wikipedia.org/wiki/ECMAScript),and now it hasnorelation to Java at all.
Pero a medida que evolucionaba, JavaScriptse convirtió en un lenguaje totalmente independiente con su propia especificación llamada[ECMAScript](http://es.wikipedia.org/wiki/ECMAScript),y ahoranotiene ninguna relación con Java.
```

Today, JavaScriptcan execute not only in the browser, but also on the server, or actually on any device that has a special program called [the JavaScript engine](https://en.wikipedia.org/wiki/JavaScript_engine).
Hoy en día, JavaScriptpuede ejecutarse no solo en el navegador, sino también en el servidor, o en cualquier dispositivo que tenga un programa especial denominado [motor de JavaScript](https://es.wikipedia.org/wiki/Intérprete_de_JavaScript).

The browser has an embedded engine sometimes called a "JavaScript virtualmachine".
El navegador tiene un motor incorporado llamado "máquina virtualde JavaScript".

Different engines have different "codenames".For example:
Diferentes motores tienen diferentes "nombres".Por ejemplo:

- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) --in Chromeand Opera.
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) --in Firefox.
- ...There are other codenames like "Trident"and "Chakra"for different versions of IE, "ChakraCore"for Microsoft Edge, "Nitro"and "SquirrelFish"for Safari, etc.
- [V8](https://es.wikipedia.org/wiki/Chrome_V8) --en Chromey Opera.
- [SpiderMonkey](https://es.wikipedia.org/wiki/SpiderMonkey) --en Firefox.
- ... Hay otros nombres como "Trident"y "Chakra"para diferentes versiones de IE, "ChakraCore"para Microsoft Edge, "Nitro"y "SquirrelFish"para Safari, etc.

The terms above are good to remember because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature Xis supported by V8",then it probably works inChromeand Opera.
Es bueno recordar los nombres anteriores porque se usan en artículos de programación. Los usaremos también. Por ejemplo, si "una característica Xes compatible con V8",entonces probablemente funcione enChromey Opera.

```smart header="How do engines work?"
```smart header="¿Cómo funcionan los motores?"

Engines are complicated. But the basics are easy.
Los motores son complicados. Pero los fundamentos son fáciles.

1.The engine (embedded if it's a browser) reads ("parses")the script.
2.Then it converts ("compiles")the scriptto the machine language.
3.And then the machine code runs, pretty fast.
1.El motor (incrustado si es un navegador) lee ("analiza")el script.
2.Luego convierte ("compila")el scriptal lenguaje máquina.
3.Y luego ejecuta el código máquina, bastante rápido.

The engine applies optimizations at each step of the process. It even watches the compiled script as it runs, analyzes the data that flows through it, and applies optimizations to the machine code based on that knowledge. When it's done,scriptsrun quite fast.
El motor aplica optimizaciones en cada paso del proceso. Incluso observa el script compilado a medida que se ejecuta, analiza los datos que fluyen a través de él y aplica optimizaciones al código de la máquina basándose en ese conocimiento. Losscriptsse ejecutan bastante rápido.
```

##What can in-browser JavaScriptdo?
##¿Qué puede hacer JavaScripten el navegador?

Modern JavaScriptis a "safe" programming language. It does not provide low-level access to memory or CPU,because it was initially created for browsers which do not require it.
El JavaScriptmoderno es un lenguaje de programación "seguro". No proporciona acceso de bajo nivel a la memoria o al CPU,ya que se creó inicialmente para los navegadores que no lo requieren.

Javascript's capabilities greatly depend on the environment it's running in. For instance, [Node.JS](https://wikipedia.org/wiki/Node.js)supports functions that allowJavaScriptto read/write arbitrary files, perform network requests, etc.
Las capacidades deJavascript dependen en gran medida del entorno en el que se ejecuta. Por ejemplo, [Node.JS](https://es.wikipedia.org/wiki/Node.js)admite funciones que permiten aJavaScriptleer/escribir archivos arbitrarios, realizar solicitudes de red, etc.

In-browserJavaScriptcan do everything related to webpage manipulation, interaction with the user, and the webserver.
En el navegadorJavaScriptpuede hacer todo lo relacionado con la manipulación de la página web, la interacción con el usuario y el servidor web.

For instance, in-browserJavaScriptis able to:
Por ejemplo,JavaScripten el navegador es capaz de:

-Add newHTMLto the page, change the existing content, modify styles.
-React to user actions, run on mouse clicks, pointer movements, key presses.
-Send requests over the network to remote servers, download and upload files (so-called[AJAX](https://en.wikipedia.org/wiki/Ajax_(programming)) and [COMET](https://en.wikipedia.org/wiki/Comet_(programming)) technologies).
-Get and set cookies,ask questions to the visitor, show messages.
-Remember the data on the client-side ("local storage").
-Agregar un nuevoHTMLa la página, cambiar el contenido existente, modificar los estilos.
-Reaccionar a las acciones del usuario, como clics del ratón, movimientos del puntero, presión de teclas.
-Envíar solicitudes a través de la red a servidores remotos, descargar y cargar archivos (las llamadas tecnologías[AJAX](https://es.wikipedia.org/wiki/AJAX) y [COMET](https://es.wikipedia.org/wiki/Comet)).
-Obtener y configurar cookies,hacer preguntas al visitante, mostrar mensajes.
-Recordar datos del lado del cliente ("local storage").

##What CAN'T in-browserJavaScriptdo?
##¿Qué NO PUEDE hacerJavaScripten el navegador?

JavaScript's abilities in the browser are limited for the sake of the user's safety. The aim is to prevent an evil webpage from accessing private information or harming the user's data.
Las capacidades de JavaScript en el navegador están limitadas para la seguridad del usuario. El objetivo es evitar que una página web maliciosa acceda a información privada o dañe los datos del usuario.

Examples of such restrictions include:
Ejemplos de tales restricciones incluyen:

- JavaScripton a webpage may not read/write arbitrary files on the hard disk, copy them or execute programs. It has no direct access to OS system functions.
- JavaScripten una página web no puede leer/escribir archivos arbitrarios en el disco duro, copiarlos o ejecutar programas. No tiene acceso directo a las funciones del sistema operativo.

Modern browsers allow it to work with files, but the access is limited and only provided if the user does certain actions, like "dropping" a file into a browser window or selecting it via an`<input>` tag.
Los navegadores modernos le permiten trabajar con archivos, pero el acceso es limitado y solo es posible si el usuario realiza ciertas acciones, como "soltar" un archivo en una ventana del navegador o seleccionarlo mediante una etiqueta`<input>`.

There are ways to interact with camera/microphone and other devices, but they require a user's explicit permission. So a JavaScript-enabled page may not sneakily enable a web-camera, observe the surroundings and send the information to the [NSA](https://en.wikipedia.org/wiki/National_Security_Agency).
-Different tabs/windows generally do not know about each other. Sometimes they do, for example when one window uses JavaScriptto open the other one. But even in this case,JavaScriptfrom one page may not access the other if they come from different sites (from a different domain, protocol or port).
Hay formas de interactuar con la cámara/micrófono y otros dispositivos, pero requieren el permiso explícito de un usuario. Por lo tanto, una página habilitada para JavaScript no puede acceder a una cámara, observar el entorno y enviar la información a la [NSA](https://es.wikipedia.org/wiki/NASA).
-Diferentes pestañas/ventanas generalmente no se conocen entre sí. A veces lo hacen, por ejemplo, cuando una ventana usa JavaScriptpara abrir otra. Pero incluso en este caso, elJavaScriptde una página no puede acceder a la otra si provienen de sitios diferentes (de un dominio, protocolo o puerto diferente).

This is called the "Same Origin Policy".To work around that, *both pages* must contain a special JavaScriptcode that handles data exchange.
Esto se llama "Política del mismo origen".Para evitar eso, *ambas páginas* deben contener un código JavaScriptespecial que maneje el intercambio de datos.

This limitation is, again, for the user's safety. A page from `http://anysite.com` which a user has opened must not be able to access another browser tab with the URL`http://gmail.com` and steal information from there.
- JavaScriptcan easily communicate over the net to the server where the current page came from. But its ability to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed in HTTP headers) from the remote side. Once again, that's a safety limitation.
Esta limitación es, nuevamente, para la seguridad del usuario. Una página dehttp://algunsitio.com que un usuario ha abierto no debe poder acceder a otra pestaña del navegador con la URL http://gmail.com y robar información desde allí.
- JavaScriptpuede comunicarse con facilidad, por medio de la red, al servidor de donde proviene la página actual. Pero su capacidad para recibir datos de otros sitios/dominios está restringido. Aunque es posible, requiere un acuerdo explícito (expresado en encabezados HTTP) desde el lado remoto. Una vez más, eso es una limitación de seguridad.

![](limitations.png)

Such limits do not exist ifJavaScriptis used outside of the browser, for example on a server. Modern browsers also allow plugin/extensions which may ask for extended permissions.
Tales límites no existen cuandoJavaScriptse usa fuera del navegador, por ejemplo, en un servidor. Los navegadores modernos también permiten complementos/extensiones que pueden solicitar permisos extendidos.

##What makesJavaScriptunique?
##¿Qué hace queJavaScriptsea único?

There are at least *three* great things about #"f9722fc4e3dc0d9e6b776b4ab90c712216ec09b0c33bd3d0441ae6a476f17830">Hay al menos *tres* grandes cosas sobre #"f9722fc4e3dc0d9e6b776b4ab90c712216ec09b0c33bd3d0441ae6a476f17830">
```compare
+Full integration with HTML/CSS.
+Simple things are done simply.
+Support by all major browsers and enabled by default.
+Integración completa con HTML/CSS.
+Las cosas simples se hacen de manera simple.
+Soporte por todos los principales navegadores y está habilitado por defecto.
```
Javascriptis the only browser technology that combines these three things.
Javascriptes la única tecnología del navegador que combina estas tres cosas.

That's what makesJavaScriptunique. That's why it's the most widespread tool for creating browserinterfaces.
Eso es lo que hace queJavaScriptsea único. Por eso es la herramienta más extendida para crearinterfaces de navegador.

While planning to learn a new technology, it's beneficial to check its perspectives. So let's move on to the modern trends affecting it, including new languages and browser abilities.
Al planear aprender una nueva tecnología, es beneficioso revisar sus perspectivas. Así que vamos a pasar a las tendencias modernas que lo afectan, incluyendo nuevos lenguajes y capacidades del navegador.


##Languages "over" JavaScript
##Lenguajes "sobre" JavaScript

The syntax of JavaScriptdoes not suit everyone's needs. Different people want different features.
La sintaxis de JavaScriptno se adapta a todas las necesidades. Diferentes personas quieren características diferentes.

That's to be expected, because projects and requirements are different for everyone.
Eso es de esperarse, porque los proyectos y los requisitos son diferentes para cada persona.

So recently a plethora of new languages appeared, which are *transpiled* (converted) to JavaScriptbefore they run in the browser.
Hace poco apareció una gran cantidad de nuevos lenguajes, que se *transpilan* (convierten) a JavaScriptantes de ejecutarse en el navegador.

Modern tools make the transpilation very fast and transparent, actually allowing developers to code in another language and auto-converting it "under the hood".
Las herramientas modernas hacen que la transpilación sea muy rápida y transparente, lo que permite a los desarrolladores codificar en otro lenguaje y convertirlo automáticamente "bajo el capó".

Examples of such languages:
Ejemplos de tales lenguajes:

- [CoffeeScript](http://coffeescript.org/)is a "syntactic sugar" for JavaScript.It introduces shorter syntax, allowing us to write clearer and more precise code. Usually, Ruby devs like it.
- [TypeScript](http://www.typescriptlang.org/)is concentrated on adding "strict data typing" to simplify the development and support of complex systems. It is developed by Microsoft.
- [Dart](https://www.dartlang.org/)is a standalone language that has its own engine that runs in non-browser environments (like mobile apps).It was initially offered byGoogleas a replacement for JavaScript,but as of now, browsers require it to be transpiled to JavaScriptjust like the ones above.
- [CoffeeScript](http://coffeescript.org/)es un "azúcar sintáctico" para JavaScript.Introduce una sintaxis más corta, lo que nos permite escribir códigos más claros y precisos. Por lo general, a los desarrolladores de Ruby les agrada.
- [TypeScript](http://www.typescriptlang.org/)se concentra en agregar "tipos de datos estrictos" para simplificar el desarrollo y el soporte de sistemas complejos. Está desarrollado por Microsoft.
- [Dart](https://www.dartlang.org/)es un lenguaje independiente que tiene su propio motor que se ejecuta en entornos sin navegador (como las aplicaciones móviles).Inicialmente, fue ofrecido porGooglecomo un reemplazo de JavaScript,pero a partir de ahora, los navegadores requieren que sea transpilado a JavaScriptcomo los anteriores.

There are more. Of course, even if we use one of these languages, we should also knowJavaScriptto really understand what we're doing.
Hay más. Por supuesto, incluso si usamos uno de estos lenguajes, también deberíamos conocerJavaScriptpara entender realmente lo que estamos haciendo.

##Summary
##Resumen

- JavaScriptwas initially created as a browser-only language, but is now used in many other environments as well.
-Today, JavaScripthas a unique position as the most widely-adopted browser language with full integration with HTML/CSS.
-There are many languages that get "transpiled" to JavaScriptand provide certain features. It is recommended to take a look at them, at least briefly, after mastering JavaScript.
- JavaScriptse creó inicialmente como un lenguaje solo para el navegador, pero ahora también se usa en muchos otros entornos.
-Hoy en día, JavaScripttiene una posición única como el lenguaje de navegador más ampliamente adoptado con integración completa con HTML/CSS.
-Hay muchos lenguajes que se "transpilan" a JavaScripty proporcionan ciertas funcionalidades. Se recomienda echarles un vistazo, al menos brevemente, después de dominar JavaScript.
Loading

[8]ページ先頭

©2009-2025 Movatter.jp