본문 바로가기
책갈피

Is 'switch' the reserved word in Javascript?

김진화 |2011.07.28 11:10
조회 7 |추천 0
P {MARGIN-TOP:2px; MARGIN-BOTTOM:2px}In short, that's true.

When you use 'switch' keyword as the function name like 'thumbRoller.switch = function() { ... };', you will encounter unexpected situation.

Safari, FF and IE on PC work strangely fine. But Safari in iPad throws an error that it cannot parse the code.

Remember, don't use the reserved word anyway. (Because there are PITFALL words like switch or goto verbs...)

The follwing are the reserved words in Javas-ript.

    (*) indicates that are reserved for the future usage.
    (2) indicates that are only used in Javascript 2.0.

    abstract (*)
    as (2)
    boolean
    break
    byte
    case
    catch
    char
    class (2)
    continue
    const (2)
    debugger (*)
    default
    delete
    do
    double
    else
    enum (*)
    export (2)
    extends (2)
    false
    final
    finally
    float
    for
    function
    goto (*)
    if
    implements (*)
    import (2)
    in
    instanceof
    int
    interface (2)
    is (2)
    long
    namespace (2)
    native (*)
    new
    null
    package (2)
    private (2)
    protected (*)
    public (2)
    return
    short
    static (2)
    super (2)
    switch
    synchronized (*)
    this
    throw
    throws (*)
    transient (*)
    true
    try
    typeof
    use (2)
    var
    void
    volatile (*)
    while
    with

Reference
    http://javascript.about.com/library/blreserved.htm
추천수0
반대수0

공감많은 뉴스 시사

더보기

뉴스 플러스