JavaScript The Definitive Guide_Chap1~3

Study notes for JavaScript

Posted by Rui on 15-09-2021
Estimated Reading Time 3 Minutes
Words 578 In Total
Viewed Times

Chapter 1-2

  1. html determine content. css determine presentation, js determine behavior
  2. curly brace; square brace; Semicolons
  3. object: properties->value
    arrays: element
  4. 赋值:assignment
    调用:invoke
    继承: inherits
    变量名:identifier
  5. && is AND; || is OR
  6. JavaScript is a case-sensitive language.
  7. Roughly, an expression is something that computes a value but doesn’t do anything: it doesn’t alter the program state in any way. Statements, on the other hand, don’t have a value (or don’t have a value that we care about), but they do alter the state.
  8. In JavaScript, you can usually omit the semicolon between two statements if those statements are written on separate lines.general rule that JavaScript interprets line breaks as semicolons when it cannot parse the second line as a continuation of the statement on the first line.
  9. object-oriented language: rather than having globally defined functions to operate on values of various types, the types themselves define methods for working with values.

Chapter 3–Types, Values, and Variables

primitive types (原始数据类型)

numbers

  1. JavaScript does not make a distinction between integer values and floating-point values. All numbers in JavaScript are represented as 64-bit floating-point values.
  2. Arithmetic in JavaScript
    JavaScript does not raise errors in cases of overflow, underflow, or divi- sion by zero.
    - Overflow: infinity, negative infinity
    - Underflow: zero, negative zero
    - Division by zero: infinity or zero infinity
    - zero divided by zero or divide infinity by infinity: NaN
  3. The not-a-number value has one unusual feature in JavaScript: it does not compare equal to any other value, including itself.
    usage: x != x. It will be true if, and only if, x is NaN.
  4. zero == negative zero, except when used as a divisor

strings

booleans

  1. Boolean values are generally the result of comparisons you make in your JavaScript programs.
  2. Boolean values are commonly used in JavaScript control structures.
  3. any JavaScript value can be converted to a boolean value. undefined; null; 0; -0; NaN; “”; convert to, and therefore work like, false. All other values, including all objects (and arrays) convert to, and work like, true.
  4. Boolean values have a toString() method that you can use to convert them to the strings “true” or “false”.
  5. there are three boolean operators:
    - AND:&&
    - OR:||
    - NOT:!

null

Using the typeof operator on null returns the string “object”, indicating that null can be thought of as a special object value that indicates “no object”.
In practice,it can be used to indicate “no value” for numbers and strings as well as objects.

undefined

typeof operator to the undefined value, it returns “undefined”, indicating that this value is the sole member of a special type, it represents a deeper kind of absence.
It is the value of variables that have not been initialized and the value you get when you query the value of an object property or array element that does not exist. The undefined value is also returned by functions that have no return value, and the value of function parameters for which no argument is supplied.

object types (对象数据类型)

Any JavaScript value that is not a number, a string, a boolean, or null or undefined is an object.
An object is a collection of properties where each property has a name and a value

objects

arrays

special kind of object, that represents an ordered collection of numbered values.

function

automatic garbage collection


If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !