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.





  • 相关阅读:
    Dotfuscator 保护您的应用程序
    IOS 类方法
    播放音乐与视频
    windows phone 手机信息的查看
    更改枢轴视图的Item字的大小
    IOS 总结
    Windows Phone 中HttpWebRequest用法
    关于Listbox的 SelectionChanged 事件 (同一个Item只触发一次问题)
    windows phone 标准色值
    IOS GPS 定位
  • 原文地址:https://www.cnblogs.com/FBsharl/p/10149832.html
Copyright © 2011-2022 走看看