📂
CS-NoteBook
  • Introduction
  • CS144
    • concise introduction to Internet
      • 1.1 Networked Applications
      • 1.2 The 4 Layer Internet
      • 1.3 IP
      • 1.4 A Day in the Life of a Packet
      • 1.5 Principle: Packet Switching
      • 1.6 Principle:Layering
      • 1.7 Principle: Encapsulation
      • 1.8 Byte order and packet formats
      • 1.9 name and addresses:IPv4
      • 1.10 Longest Prefix Match for Link Layer
      • 1.11 Address Resolution Protocol(ARP)
      • 1.12 Summary
    • Transport Layer
      • 2.1 The TCP Service Model
      • 2.2 UDP service model
      • 2.3 ICMP(Internet Control Message Protocol 互联网报文控制协议)
      • 2.4 The End-to-End Principle
      • 2.5 Error Detection:3 schemes (Checksum,CRC and MAC)
      • 2.6 Finite State Machines(有限状态机)
      • 2.7 Flow Control
      • 2.8 Sliding window
      • 2.9 Retransmission Strategies
      • 2.10 TCP Header
      • 2.11 TCP Setup and Teardown
      • 2.12 Recap
    • Package Switching
      • 3.1 The history of Internet
      • 3.2 What is packet switching
      • [3.3 End-to-end delay and Queueing delay
      • 3.4 Playback Buffer(回放缓存区)
  • CS 61C
    • 1.4 C Memory Mangement, Usage
    • 1.5 Intro to Assembly Language, MIPS Intro
    • 1.5 extra bits operation
  • CS 61B
  • CS 61A
    • Function
    • Names
    • The Art of the Function
    • Control
    • Higher-Order Function
    • Recursive Function
    • List
    • Non-Local Assignment
    • Iterators
    • Objects
    • Data Abstraction
    • OOP
    • Inheritance
    • Representations
    • Decomposition
    • Scheme
    • Exceptions
    • Calculator
    • Interpreters
    • Declarative_Programming
    • Table
    • Aggregation
      • More_recursion
    • Databases
    • Distributed_Data
    • Tail Recursion
    • Exercises
      • lab00
      • lab01
      • hw01
      • tree Recursion example -- give Change
  • The Web DevelopMent Bootcamp
    • html5
    • css
    • bootstrap3
    • bootstrap4
    • javascript expression
    • javascript function
Powered by GitBook
On this page
  • alert prompt console.log
  • Comparison Operators
  • substring
  • forloop

Was this helpful?

  1. The Web DevelopMent Bootcamp

javascript expression

Previousbootstrap4Nextjavascript function

Last updated 5 years ago

Was this helpful?

// 所有基本的算数运算都如你预期。
1 + 1; // = 2
0.1 + 0.2; // = 0.30000000000000004
8 - 1; // = 7
10 * 2; // = 20
35 / 5; // = 7

// 基本变量
var

// 也有布尔值。
true;
false;

// 可以通过单引号或双引号来构造字符串。
'abc';
"Hello, world";

null;      // 用来表示刻意设置的空值
undefined; // 用来表示还没有设置的值(尽管`undefined`自身实际是一个值)

// es6 新增
let name = 'dog';
var name2 = 'cat';
const age = '10'; //const声明额变量不能改变,所以,const一旦声明一个变量,就必须马上初始化,不能留到以后赋值
console.log(window.name);  //undefined
console.log(window.name2); // 'cat'

var x = 10;
var x = "abc"; // OK

let y = 10;
let y = "abc"; // ERROR

alert prompt console.log

alert("abc"); // 只是显示警示
console.log("abc"); // 只在 console 打印
let texts = prompt("some text"); // 给用户输入内容来交互

Comparison Operators

// Comparison Operators
// x = 5
x == "5" // true, Equal to
x != "5" // false

x === "5" // false, Equal value and type
x !== "5" // true, Not equal value or equal type

// y = null
y == undefined // true
y === undefined // false

// == 强制类型转换

// 例外:
// NaN与任何值都不相等,包括NaN自身
NaN == NaN //false
NaN === NaN // false

// !!来判断某个东西的真假
!"hello" //false

!!"hello" //true
!!""  //false
!!null //false
!!0 //false
!!NaN // false
!!-1 // true

// Flasy Values: false,0,"",null,undefined,NaN

substring

let answer = "okyes";
answer.indexOf('yes'); // 2 
answer.indexOf('aaa'); // -1

forloop

for(init; condition; step) {}
for(let i = 0; i < 3; i++) {}
X分钟速成Javascript