function addTax(total) { return total * 1.05; }
addTax = 50;
return addTax 50;
addTax(50);
addTax 50;
let rate = 100;
let 100 = rate;
100 = let rate;
rate = 100;
var student = new Person();
var student = construct Person;
var student = Person();
var student = construct Person();
let modal = document.querySelector('#result'); setTimeout(function () { modal.classList.remove('hidden'); }, 10000); console.log('Results shown');
class Animal { static belly = []; eat() { Animal.belly.push('food'); } } let a = new Animal(); a.eat(); console.log(/* Snippet Here */); //Prints food
a.prototype.belly[0]
Object.getPrototype0f (a).belly[0]
Animal.belly[0]
a.belly[0]
A
for (var i = 1; i <= 4; i++) { setTimeout(function () { console.log(i); }, i * 10000); }
B
for (var i = 1; i <= 4; i++) {
(function (i) {
setTimeout(function () {
console.log(j);
}, j * 1000);
})(j);
}
C
for (var i = 1; i <= 4; i++) { setTimeout(function () { console.log(i); }, i * 1000); }
D
for (var i = 1; i <= 4; i++) {
(function (j) {
setTimeout(function () {
console.log(j);
}, j * 1000);
})(i);
}
E
for (var j = 1; j <= 4; j++) {
setTimeout(function () {
console.log(j);
}, j * 1000);
}
A
let discountPrice = function (price) { return price * 0.85; };
B
let discountPrice(price) {
return price * 0.85;
};
C
let function = discountPrice(price) { return price * 0.85; };
D
discountPrice = function (price) { return price * 0.85; };
var Storm = function () {};
Storm.prototype.precip = 'rain';
var WinterStorm = function () {};
WinterStorm.prototype = new Storm();
WinterStorm.prototype.precip = 'snow';
var bob = new WinterStorm();
console.log(bob.precip);
/[0-9]{2,}:[0-9]{2,}:[0-9]{2,}/
/\d\d:\d\d:\d\d/
/[0-9]+:[0-9]+:[0-9]+/
/ : : /
注意:前三个部分都部分正确,会匹配数字,但第二个选项最正确,因为它只匹配2 位数字的时间值(12:00:32)。第一个选项如果重复范围看起来像 [0-9]{2}
,则会起作用,但由于逗号 [0-9]{2,}
的存在,它将选择 2 个或更多位数(120:000:321)。第三个选项将匹配任何范围的时间数字,单个和多个(这意味着 1:2:3
也会匹配)。
更多资源:
'use strict';
function logThis() {
this.desc = 'logger';
console.log(this);
}
new logThis();
undefined
window
{desc: "logger"}
function
let roadTypes = ['street', 'road', 'avenue', 'circle'];
console.log(typeof 42);
'float'
'value'
'number'
'integer'
function addNumbers(x, y) {
if (isNaN(x) || isNaN(y)) {
}
}
exception('One or both parameters are not numbers')
catch('One or both parameters are not numbers')
error('One or both parameters are not numbers')
throw('One or both parameters are not numbers')
JSON.fromString();
JSON.parse()
JSON.toObject()
JSON.stringify()
for (var i = 0; i < 5; i++) { console.log(i); }