JavaScript Bible, Gold Edition part 125

JavaScript Bible, Gold Edition part 125. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 1088 Part IV JavaScript Core Language Reference The conditional operator is a shortcut way of expressing an if. . .else conditional construction covered in Chapter 39. This operator is typically used in concert with an assignment operator to assign one of two values to a variable based on the result of a condition expression. The formal syntax for the conditional operator is condition expressionIfTrue expressionIfFalse If used with an assignment operator the syntax is var condition expressionIfTrue expressionIfFalse No matter how you use the operator the important point to remember is that an expression that contains this operator evaluates to one of the two expressions following the question mark symbol. In truth either expression could invoke any JavaScript including calling other functions or even nesting further conditional operators within one of the expressions to achieve the equivalent of nested if. . .else constructions. To assure proper resolution of nested conditionals surround inner expressions with parentheses to make sure that they evaluate before the outer expression evaluates. As an example the following statement assigns one of three strings to a variable depending on the date within a month var monthPart dateNum 10 early dateNum 20 middle late When the statement is evaluated the inner conditional expression at the right of the first colon is evaluated returning either middle or late then the outer conditional expression is evaluated returning either early or the result of the inner conditional expression. typeof NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility Unlike most other operators which are predominantly concerned with arithmetic and logic the unary typeof operator defines the kind of value to which a variable or expression evaluates. Typically this operator is used to identify whether a variable value is one of the following types number string boolean object function or undefined. Having this investigative capability in JavaScript

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.