zoukankan      html  css  js  c++  java
  • JavaScript 第二章总结

    Writing real code

    设计程序的步骤

    1. First, a high-level design and a flowchart
    2. more details
    3. Working through the Psedocode:作者将 psedocode 分为了两个部分,分别是 variables 和 logic ,它们的作用分别是

    The variables will tell us what we need to keep track of in our code, and the logic describes what the code has to faithfully implement to create the game.(And using indentation to help make the psedocode easier to read.)

    认识 boolean operators

    boolean opetators 有两种:comparison operators 和 logical operators.

    • Comparison Operators compare two values
    • Logical Operatore combine two boolean expessions to create one boolean result

    一些 JavaScript 的 bultin-functions

    alert("content")

    用于显示一个含有 content 的 dialogue box.

    prompt("prompt")

    作用:和 alert 特别像,另外还有一个可供 User 输入的输入框,User 在里面的输入值称为这个函数的返回值。这个输入值的类型是 string 类型的。
    注意:在这里和 C 语言有一点不同的是:当你输入一个数字的时候,返回的时候是一个字符,但是如果写成和另外一个数字比较的形式,JavaScript 会自动将这个字符串转换为数字。

    Math.random()

    Mathrandom()没有参数,返回一个0~1的数(including 0, but not including 1),如果想要一个0~(n-1).9999的数,可以这样写:var randomLoc = Math.random()*n

    Math.floor(num)

    Math.floor()用于将 num round down to their nearest interger value.





  • 相关阅读:
    leetcode第四题
    解决Hystrix主线程结束,子线程拿不到request
    RabbitMQ如何保证消息的顺序性+解决消息积压+设计消息队列中间件
    RabbitMQ 如何保证消息不丢失?
    redis布隆过滤器的使用
    PageHelper自定义count
    mysqlbinlog 工具分析binlog日志
    linuxubuntu常用命令
    MySQL 常用命令
    Ubuntu 16.04 安装 Apache, MySQL, PHP7
  • 原文地址:https://www.cnblogs.com/FBsharl/p/10149832.html
Copyright © 2011-2022 走看看