Javascript 学习第一天
Javascript 学习第一天
掉包虾 发表于2年前
Javascript 学习第一天
  • 发表于 2年前
  • 阅读 46
  • 收藏 0
  • 点赞 2
  • 评论 0

腾讯云 技术升级10大核心产品年终让利>>>   

摘要: Eloquent JavaScript 书籍

There are six basic types of values in JavaScript numbers, strings, Booleans, objects, functions, and undefined values.

**Number : > 粗体 Notice 2.998e8 ** scientific notation “e” (for “exponent”) 2.998 × 10^8 = 299,800,000.

print == console.log(typeof "x")

JavaScript has a Boolean type, which has just two values: true and false

0 == false and "" == false are also true === and !==.

The first tests whether a value is precisely equal to the other. the second tests whether it is not precisely equal.

Logical operators

console.log(8 * null)
// → 0
console.log("5" - 1)
// → 4
console.log("5" + 1)
// → 51
console.log("five" * 2)
// → NaN
console.log(false == 0)
// → true

Function

  • alert("Good morning!");
  • The console.log function
console.log("the value of x is", x);
// → the value of x is 30
  • prompt and confirm confirm("Shall we, then?"); . This returns a Boolean: true if the user clicks OK false if the user clicks Cancel.

Control flow

if (num < 10)
  alert("Small");
else if (num < 100)
  alert("Medium");
else
  alert("Large");

Defining a function

var square = function(x) {
  return x * x;
};

console.log(square(12));
// → 144

The function body must always be wrapped in braces, even when it consists of only a single statement

js array vs python list

push == append

var mack = [];
mack.push("Mack");
mack.push("the", "Knife");
console.log(mack);
// → ["Mack", "the", "Knife"]
console.log(mack.join(" "));
// → Mack the Knife
console.log(mack.pop());
// → Knife
标签: javascript
共有 人打赏支持
粉丝 3
博文 29
码字总数 6635
×
掉包虾
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: