Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
E

Eddie Kuns

@Eddie Kuns
About
Posts
1
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I Hate Clever Javascript Programmers [modified]
    E Eddie Kuns

    If I read this correctly and my understanding of JavaScript precedence is correct, I think this is an ugly version of a big else-if statement. Something like this:

    if (aw == null) {
    return a0 === "!=";
    } else if (a0 === "=") {
    return a2 === aX;
    } else if (a0 === "*=") {
    return a2.indexOf(aX) >= 0;
    } else if (a0 === "~=") {
    return (" " + a2 + " ").indexOf(aX) >= 0;
    } else if (!aX) {
    return a2 && aW !== false;
    } else if (a0 === "!=") {
    return a2 !== aX;
    } else if (a0 === "^=") {
    return a2.indexOf(aX) === 0;
    } else if (a0 === "$=") {
    return a2.substr(a2.length - aX.length) === aX;
    } else if (a0 === "|=") {
    return a2 === aX || a2.substr(0, aX.length + 1) === aX + "-";
    }

    return false;

    which you could also write as

    return (aW == null) ? a0 === "!="
    : (a0 === "=") ? a2 === aX
    : (a0 === "*=") ? a2.indexOf(aX) >= 0
    : (a0 === "~=") ? (" " + a2 + " ").indexOf(aX) >= 0
    : (!aX) ? a2 && aW !== false
    : (a0 === "!=") ? a2 !== aX
    : (a0 === "^=") ? a2.indexOf(aX) === 0
    : (a0 === "$=") ? a2.substr(a2.length - aX.length) === aX
    : (a0 === "|=") ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-"
    : false;

    where this shows the IF on the left and the RETURN THIS on the left of the "?" on each line. Ugly. Un-maintainable. Yuck.

    The Weird and The Wonderful javascript question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups