JavaScript的7种数据类型
undefined
null
number
string
boolean
object
symbol
数组的push函数(插入一个元素到最后)
,pop函数(移除最后一个元素)
,shift函数(移除第一个元素)
,unshift函数(插入第一个元素)
全等(===)是相对于相等操作符(==)的一种操作符。与相等操作符不同的是全等比较严格,它会同时比较元素的值和 数据类型。
不全等运算符(!==)与全等运算符是相反的。这意味着“不全等”并返回 false 的地方,用全等运算会返回 true,反之亦然。全等运算符不会转换值的数据类型。
我们同样可以删除对象的属性,例如:
delete ourDog.bark;
JavaScript 检查对象属性
有时检查一个对象属性是否存在是非常有用的,我们可以用.hasOwnProperty(propname)方法来检查对象是否有该属性。如果有返回true,反之返回 false。
slotOne = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;
$($(‘.slot‘)[0]).html(‘<img src = "‘ + images[slotOne-1] + ‘">‘);
$($(‘.slot‘)[1]).html(‘<img src = "‘ + images[slotTwo-1] + ‘">‘);
$($(‘.slot‘)[2]).html(‘<img src = "‘ + images[slotThree-1] + ‘">‘);