- все идентификаторы регистрозависимы,
- в названиях переменных можно использовать буквы, подчёркивание, символ доллара, арабские цифры,
- названия переменных не могут начинаться с цифры,
- для оформления однострочных комментариев используются
//
, многострочные и внутристрочные комментарии начинаются с/*
и заканчиваются*/
.
- ; точка с запятой в конце строки указывает на то, что строка JavaScript закончена. Без нее браузер решил бы, что команда продолжается на следующей строке.
- Текст, видимый на странице, должен быть окружен двойными кавычками (это, типа, обычные кавычки). н-р: document.write("Сегодня ")
- одинарные кавычки (типа, апостроф вместо кавычек открывающих и еще один вместо закрывающих) для кода HTML внутри двойных. н-р: document.write("<FONT COLOR='RED'>Это красный текст</FONT>")
- сочетание текста и команд требует знака «плюс» + между элементами.
н-р:
document.write("Сегодня " + Now.getDate()
+ Now.getSeconds()
+
" секунд.") - Объект и метод разделены точкой.
ключевые слова и операторы в JavaScript:
каждый из них является ссылкой на описание самое себя.
часть описаний оказалась некорректна. их я заменила на более удачные, однако ссылки не убрала.
ежели кто, заглянув сюда, обнаружит ошибку или неточность, пожалуйста, пишите!
операторы, творящие чего-то там с битами я пока не разбирала и не переводила.
операторы, творящие чего-то там с битами я пока не разбирала и не переводила.
//
для оформления однострочных комментариев или превращения в коммент. одной строчки кода
/* */
многострочные и внутристрочные комментарии
+
Adds two values together or concatenates two strings into a single string.
добавление двух значений одновременно или связки двух строк в одну
-
Subtracts the value of a number from another number.
вычитание чисел
*
Multiples the values of two numbers.
умножение чисел
/
Divides a number by another number.
деление чисел
%
Divides a number by another number and returns the remainder.
"возвращает" остаток от деления одного числа на другое
синтаксис: numberA % numberB
пример: myModulus = 11 % 2;
//myModulus = 1;
++
Increments the value of a number by 1.
увеличивает значение числа на 1. то же, что +1
синтаксис: number++ или ++number
пример: var myNumber = 3;
myNumber++;
// myNumber = 4;
--
Decrements the value of a number by 1.
уменьшает значение числа на 1
- (unary - одинарный)
Changes the sign of a signed integer.
изменение знака целого числа на противоположный
синтаксис: -number
пример: var myNumber = 3;
-myNumber; // myNumber = -3;
=
Assigns a value to a variable or other object.
присваивает значение переменной или другому объекту
+=
Adds the value of the first item to the second item and assigns the total to the first item as a new value.
сумму прервого и второго присваивает первому в качестве нового значения
синтаксис: valueA += valueB
пример: var foo = 7;
var bar = 3;
foo += bar; //now foo = 10;
-=
Subtracts the value of the second item from the first item and assigns the total to the first item as a new value.
вычитает значение второго элемента из первого. полученный результат присваивается первому в качестве нового значения.
*=
Multiples the value of the first item by the second item and assigns the total to the first item as a new value.
перемножает значения первого и второго элемента. полученный результат присваивается первому в качестве нового значения.
/=
Divides the value of the first item by the second item and assigns the total to the first item as a new value.
значение первого элемента делится на значение второго. полученный результат присваивается первому в качестве нового значения.
>>= !
Shifts the first item in binary representation the value of the second item of bits to the right, discarding bits shifted off, and assigns the new value to the first item.
<<=!
Shifts the first item in binary representation the second item of bits to the left, shifting in zeros from the right, and assigns this total to the first item.
>>>=!
Shifts the first item in binary representation the value of the second item bits to the right, discarding bits shifted off, shifting in zeros from the left, and assigns this total to the first item.
&=
Returns the value of the first item one in each bit position for which the corresponding bits of both operands are ones, and assigns the new value to the first item.
|=
Returns the value of the first item one in each bit position for which the corresponding bits of either or both operands are ones, and assigns the new value to the first item.
^=
Returns the value of the first item one in each bit position for which the corresponding bits of either but not both operands are ones, and assigns the new value to the first item.
&
Returns the value of the first item one in each bit position for which the corresponding bits of both operands are ones.
значени
|
Returns the value of the first item one in each bit position for which the corresponding bits of either or both operands are ones.
значени
^
Returns the value of the first item one in each bit position for which the corresponding bits of either but not both operands are ones.
~
Reverses the bits of the value.
<<
Shifts the first item in binary representation the second item of bits to the left, shifting in zeros from the right.
>>
No description provided.
>>>
Shifts the first item in binary representation the value of the second item bits to the right, discarding bits shifted off, shifting in zeros from the left
==
Returns true if both values are equal.
"возвращает" - "верно", если два значения равны
!=
Returns true if the two values are not equal.
"возвращает" - "верно", если два значения не равны
===
Returns true if both values are of the same type and are equal.
"возвращает" - "верно", если оба значения одного типа и равны
!==
Returns true if the two values are either of different types or are different values.
"возвращает" - "верно", если значения не равны, либо разного типа.
>
Returns true if the value of the first item is greater than the value of the second item.
"возвращает" - "верно", если значение первого элемента больше, чем значение второго.
>=
Returns true if the value of the first item is greater or equal to than the value of the second item.
"возвращает" - "верно", если значение первого элемента больше или равно, чем значение второго.
<
Returns true if the value of the first item is less than the value of the second item.
возвращает "верно", если значение первого элемента меньше значения второго
<=
Returns true if the value of the first item is less than or equal to the value of the second item.
&&
Returns true if both the first and second expression evaluate to true.
возвращает "верно", если оба выражения верны
||
Returns true if either the first or second expression evaluate to true.
возвращает "верно", если одно из выражений верно
!
Inverts the boolean value of the expression.
инвертирует булево значение выражения (меняет "верно" на "неверно" и наоборот)
, (запятая)
ну просто запятая. типа, теперь делаем что-то А и что-тоВ
break
Breaks out of the current loop, switch, or labeled statement.
задает выход из цикла
const
Declares a read-only constant.
заявляет о констатне
condition ? ifTrue : ifFalse
Evaluates an expression, and does the first statement if the expression is true, or the second statement if the expression is false.
определяет значение выражения. если оно верно, выполняет первый оператор, если ложно - второй. (Shortcut for the "if" statement.)
continue
In a while loop, jumps back to the condition statement. In a for loop, jumps to the update statement.
delete
Deletes an object, a property of an object, or an element in an array at the specified index.
do...while
операция выполняется, пока верно определенное выражение/условие
от порядка действий зависит результат:
пример1: i=1
do {
document.write(i + ",");
i += 2;
} while (i < 20); //Alerts "i" until "i" reaches 20.
присваивается значение переменной i
выполняется операция (в данном случае печатается значение переменной)
изменяется значение i
проверка, удовлетворяет ли новое значение условию i<20
если да - опять выполняется операция, нет - выход из цикла
пример2: i=1
do {
i += 2;
document.write(i + ",");
} while (i < 20); //Alerts "i" until "i" reaches 20.
присваивается значение переменной i
изменяется значение i
выполняется операция (в данном случае печатается значение переменной)
проверка, удовлетворяет ли новое значение условию i<20
если да - опять изменяется значение i и выполняется операция
export
Allows properties, functions, and objects from one script to be accessed by other scripts.
for
пример: for(i=0;i<10;i++)
doSomething();
после присвоения переменной начального значения
выполняется следующая строка, затем
выполняется операция с i (в данном случае приращение )
затем проверка условия. если оно верно - выполняется тело цикла (следующая строка, к-рой здесь нет)
цикл выполняется пока переменная меньше 10.
for...in
Loops through the properties of an object.
function
Declares a function.
if...else
If the expressionA is true, executes statementA. If the expression is false, evaluates expressionB. If expressionB is true, executes statementB. Otherwise, executes statementC.
import
Imports properties, functions, and objects from a script that has exported them.
in
Returns true if the specified property name can be found in the specified object.
instanceOf
Returns true if the specified object is of the specified object type.
label
Labels a statement with an identifier.
let
Labels a statement with an identifier.
new
Creates an instance of an object type that has a constructor function.
return
Specifies the value to be returned by a function.
switch
Evaluates an expression, and executes the statement(s) associated with the appropriate case for the value of the expression.
this
Refers to the calling object of a property.
throw
Specifies an exception to throw when an error occurs.
try...catch
Tries to execute the tryStatment, and executes the appropriate catch statement if there is an exception.
typeof
Returns the type of the specified variable.
var
Declares a variable and sets its initial value (if specified).
void
Evaluates the specified expression without returning a value.
while
Executes a statement while the specified expression is true.
операция выполняется, пока верно определенное выражение/условие
синтаксис: while (условие)
statement
пример1: n = 0;
while (n < 20) {
n ++;
doSomething(); //Will "doSomething" three times--until n is no longer less than three.
}
если n<20, прибавляем единицу и выполняем следующую строку.
полученная последовательность будет начинаться с n+1,
пример2: n = 0;
while (n < 20) {
doSomething(); //Will "doSomething" three times--until n is no longer less than three.
n ++;
}
в этом примере
n+1 идет после выполнения doSomthing,
проверка n<20 - после n+1
полученная последовательность будет начинаться с первого, присвоенного значения переменнойwith
Temporarily modifies the scope chain of a statement.
yield
Generator that returns the value for each step in a loop.
Комментариев нет:
Отправить комментарий