小编R E*_*rth的帖子

Javascript函数中的奇怪行为

如果我在以下代码片段中执行测试函数:

function pointInside( r, p ) {
    var result =
        ( p.x >= r.location.x - r.size.width * 0.5 ) &&
        ( p.x <= r.location.x + r.size.width * 0.5 ) &&
        ( p.y >= r.location.y - r.size.height * 0.5 ) &&
        ( p.y <= r.location.y + r.size.height * 0.5 )
    ;
    return result;
}

function test() {
    var rect = {};
    rect["location"] = { x:6, y:5 };
    rect["size"] = { width:10, height:8 };
    var p = { x:10, y:8 };
    var …
Run Code Online (Sandbox Code Playgroud)

javascript expression boolean

11
推荐指数
2
解决办法
264
查看次数

标签 统计

boolean ×1

expression ×1

javascript ×1