Javascript [Electronic resources] : The Definitive Guide (4th Edition) نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Javascript [Electronic resources] : The Definitive Guide (4th Edition) - نسخه متنی

David Flanagan

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







6.1 Expression Statements


The

simplest
kinds of statements in JavaScript are expressions that have side
effects. We've seen this sort of statement in Chapter 5. Assignment statements are one major category
of expression statements. For example:

s = "Hello " + name;
i *= 3;

The increment and decrement
operators, ++ and
--, are related to assignment statements. These
have the side effect of changing a variable value, just as if an
assignment had been performed:

counter++;

The delete

operator
has the important side effect of deleting an object property. Thus,
it is almost always used as a statement, rather than as part of a
larger expression:

delete o.x;

Function calls are another major
category of expression statements. For example:

alert("Welcome, " + name);
window.close( );

These client-side function calls are expressions, but they also
affect the web browser, so they are statements, too. If a function
does not have any side effects, there is no sense in calling it,
unless it is part of an assignment statement. For example, you
wouldn't just compute a cosine and discard the result:

Math.cos(x);

Instead, you'd compute the value and assign it to a variable
for future use:

cx = Math.cos(x);

Again, please note that each line of code in each of these examples
is terminated with a semicolon.



    / 844