remove cut
This commit is contained in:
parent
37f1936622
commit
be007e78ef
99 changed files with 0 additions and 198 deletions
|
@ -7,8 +7,6 @@ But, we need a working environment to run our scripts, and, just because this bo
|
|||
So first, let's see how to attach a script to a webpage. For server-side environments, you can just execute it with a command like `"node my.js"` for Node.JS.
|
||||
|
||||
|
||||
[cut]
|
||||
|
||||
## The "script" tag
|
||||
|
||||
JavaScript programs can be inserted in any part of an HTML document with the help of the `<script>` tag.
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
The first thing to study is the building blocks of the code.
|
||||
|
||||
[cut]
|
||||
|
||||
## Statements
|
||||
|
||||
Statements are syntax constructs and commands that perform actions.
|
||||
|
|
|
@ -6,8 +6,6 @@ That had the benefit of never breaking existing code. But the downside was that
|
|||
|
||||
It had been so until 2009 when ECMAScript 5 (ES5) appeared. It added new features to the language and modified some of the existing ones. To keep the old code working, most modifications are off by default. One needs to enable them explicitly with a special directive `"use strict"`.
|
||||
|
||||
[cut]
|
||||
|
||||
## "use strict"
|
||||
|
||||
The directive looks like a string: `"use strict"` or `'use strict'`. When it is located on the top of the script, then the whole script works the "modern" way.
|
||||
|
|
|
@ -6,8 +6,6 @@ Most of the time, a JavaScript application needs to work with information. Here
|
|||
|
||||
Variables are used to store this information.
|
||||
|
||||
[cut]
|
||||
|
||||
## A variable
|
||||
|
||||
A [variable](https://en.wikipedia.org/wiki/Variable_(computer_science)) is a "named storage" for data. We can use variables to store goodies, visitors and other data.
|
||||
|
|
|
@ -12,8 +12,6 @@ Programming languages that allow such things are called "dynamically typed", mea
|
|||
|
||||
There are seven basic data types in JavaScript. Here we'll study the basics, and in the next chapters we'll talk about each of them in detail.
|
||||
|
||||
[cut]
|
||||
|
||||
## A number
|
||||
|
||||
```js
|
||||
|
|
|
@ -6,8 +6,6 @@ For example, `alert` automatically converts any value to a string to show it. Ma
|
|||
|
||||
There are also cases when we need to explicitly convert a value to put things right.
|
||||
|
||||
[cut]
|
||||
|
||||
```smart header="Not talking about objects yet"
|
||||
In this chapter we don't cover objects yet. Here we study primitives first. Later, after we learn objects, we'll see how object conversion works in the chapter <info:object-toprimitive>.
|
||||
```
|
||||
|
|
|
@ -4,8 +4,6 @@ Many operators are known to us from school. They are addition `+`, a multiplicat
|
|||
|
||||
In this chapter we concentrate on aspects that are not covered by school arithmetic.
|
||||
|
||||
[cut]
|
||||
|
||||
## Terms: "unary", "binary", "operand"
|
||||
|
||||
Before we move on, let's grasp the common terminology.
|
||||
|
|
|
@ -7,8 +7,6 @@ Many comparison operators we know from maths:
|
|||
- Equality check is written as `a == b` (please note the double equation sign `=`. A single symbol `a = b` would mean an assignment).
|
||||
- Not equals. In maths the notation is <code>≠</code>, in JavaScript it's written as an assignment with an exclamation sign before it: <code>a != b</code>.
|
||||
|
||||
[cut]
|
||||
|
||||
## Boolean is the result
|
||||
|
||||
Just as all other operators, a comparison returns a value. The value is of the boolean type.
|
||||
|
|
|
@ -4,8 +4,6 @@ This part of the tutorial aims to cover JavaScript "as is", without environment-
|
|||
|
||||
But still we use a browser as the demo environment. So we should know at least a few user-interface functions. In this chapter we'll get familiar with the browser functions `alert`, `prompt` and `confirm`.
|
||||
|
||||
[cut]
|
||||
|
||||
## alert
|
||||
|
||||
Syntax:
|
||||
|
|
|
@ -4,8 +4,6 @@ Sometimes we need to perform different actions based on a condition.
|
|||
|
||||
There is the `if` statement for that and also the conditional (ternary) operator for conditional evaluation which we will be referring as the “question mark” operator `?` for simplicity.
|
||||
|
||||
[cut]
|
||||
|
||||
## The "if" statement
|
||||
|
||||
The `if` statement gets a condition, evaluates it and, if the result is `true`, executes the code.
|
||||
|
|
|
@ -6,8 +6,6 @@ Although they are called "logical", they can be applied to values of any type, n
|
|||
|
||||
Let's see the details.
|
||||
|
||||
[cut]
|
||||
|
||||
## || (OR)
|
||||
|
||||
The "OR" operator is represented with two vertical line symbols:
|
||||
|
|
|
@ -6,8 +6,6 @@ For example, when we need to output goods from a list one after another. Or just
|
|||
|
||||
*Loops* are a way to repeat the same part of code multiple times.
|
||||
|
||||
[cut]
|
||||
|
||||
## The "while" loop
|
||||
|
||||
The `while` loop has the following syntax:
|
||||
|
|
|
@ -4,8 +4,6 @@ A `switch` statement can replace multiple `if` checks.
|
|||
|
||||
It gives a more descriptive way to compare a value with multiple variants.
|
||||
|
||||
[cut]
|
||||
|
||||
## The syntax
|
||||
|
||||
The `switch` has one or more `case` blocks and an optional default.
|
||||
|
|
|
@ -6,8 +6,6 @@ For example, we need to show a nice-looking message when a visitor logs in, logs
|
|||
|
||||
Functions are the main "building blocks" of the program. They allow the code to be called many times without repetition.
|
||||
|
||||
[cut]
|
||||
|
||||
We've already seen examples of built-in functions, like `alert(message)`, `prompt(message, default)` and `confirm(question)`. But we can create functions of our own as well.
|
||||
|
||||
## Function Declaration
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
In JavaScript, a function is not a "magical language structure", but a special kind of value.
|
||||
|
||||
[cut]
|
||||
|
||||
The syntax that we used before is called a *Function Declaration*:
|
||||
|
||||
```js
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
This chapter briefly recaps the features of JavaScript that we've learned by now, paying special attention to subtle moments.
|
||||
|
||||
[cut]
|
||||
|
||||
## Code structure
|
||||
|
||||
Statements are delimited with a semicolon:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue