【发布时间】:2013-04-05 11:19:26
【问题描述】:
我正在尝试学习在 JavaScript 中进行面向对象的编程并严格违反 JSLint。我知道我在非全局上下文中使用它(或类似的东西......),但我不知道如何正确地做到这一点。这是我的代码:
function piece(color, type, x, y, captured, hasMoved) {
"use strict";
this.color = color;
this.type = type;
this.x = x;
this.y = y;
this.captured = captured;
this.hasMoved = hasMoved;
this.movePiece = movePiece;
function movePiece(x, y) {
// if(isLegal(x, y, this.type){
// this.x = x;
// this.y = y;
// }
alert("you moved me!");
}
}
var whitePawn1 = piece("white", "pawn", 0, 1, false, false);
var blackBishop1 = piece("black", "bishop", 8, 3, false, false);
【问题讨论】:
-
具体的jslint消息是什么?
标签: javascript jslint strict use-strict