up
This commit is contained in:
parent
15019c18d6
commit
db39a8be86
3 changed files with 27 additions and 8 deletions
|
@ -1,12 +1,12 @@
|
||||||
# if (строка с нулём)
|
# if (a string with zero)
|
||||||
|
|
||||||
[importance 5]
|
[importance 5]
|
||||||
|
|
||||||
Выведется ли `alert`?
|
Will `alert` be shown?
|
||||||
|
|
||||||
```js
|
```js
|
||||||
if ("0") {
|
if ("0") {
|
||||||
alert( 'Привет' );
|
alert( 'Hello' );
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,12 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script>
|
||||||
var value = prompt('Каково "официальное" название JavaScript?', '');
|
var value = prompt('What is the "official" name of JavaScript?', '');
|
||||||
|
|
||||||
if (value == 'EcmaScript') {
|
if (value == 'EcmaScript') {
|
||||||
alert('Верно!');
|
alert('Right!');
|
||||||
} else {
|
} else {
|
||||||
alert('Не знаете? "EcmaScript"!');
|
alert("Didn't know? EcmaScript!");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -43,16 +43,35 @@ We'll cover working with numbers in the chapter [](/number).
|
||||||
```js
|
```js
|
||||||
var str = "Hello";
|
var str = "Hello";
|
||||||
var str2 = 'Single quotes are ok too';
|
var str2 = 'Single quotes are ok too';
|
||||||
var prase = `can embed ${str}`;
|
var phrase = `can embed ${str}`;
|
||||||
```
|
```
|
||||||
|
|
||||||
In JavaScript, there are 3 types of quotes.
|
In JavaScript, there are 3 types of quotes.
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>Double quotes and single quotes are essentially the same.</li>
|
<li>Double quotes: `"Hello"`.</li>
|
||||||
|
<li>Single quotes: `'Hello'`.</li>
|
||||||
<li>Backtricks are "extended functionality" quotes. They allow to embed other variables or even expressions into the string wrapping them by `${…}`.</li>
|
<li>Backtricks are "extended functionality" quotes. They allow to embed other variables or even expressions into the string wrapping them by `${…}`.</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
|
Double and single quotes are essentially the same. The only difference between them can be seen when the string includes the quotation character `"` or `'`.
|
||||||
|
|
||||||
|
A double quote symbol may appear inside single-quoted lines and vise versa:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var hello = "I'm JavaScript"; // single-quote inside "…"
|
||||||
|
var name = 'My "official" name is "EcmaScript"'; // vise versa
|
||||||
|
```
|
||||||
|
|
||||||
|
If we want to include a single quote inside a same-quoted string, we can do it too. But we need to prepend it with a slash:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// prepend ' inside the string with a slash \'
|
||||||
|
var hello = 'I\'m JavaScript';
|
||||||
|
```
|
||||||
|
|
||||||
|
Similarly with double quotes.
|
||||||
|
|
||||||
[smart header="There is no *character* type."]
|
[smart header="There is no *character* type."]
|
||||||
In some languages, there is a special "character" type for a single character. For example, in the C language it is `char`.
|
In some languages, there is a special "character" type for a single character. For example, in the C language it is `char`.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue