Js的關鍵字

JavaScript 保留關鍵字

abstract

arguments

boolean

break

byte

case

catch

char

class*

const

continue

debugger

default

delete

do

double

else

enum*

eval

export*

extends*

false

final

finally

float

for

function

goto

if

implements

import*

in

instanceof

int

interface

let

long

native

new

null

package

private

protected

public

return

short

static

super*

switch

synchronized

this

throw

throws

transient

true

try

typeof

var

void

volatile

while

with

yield


 

Javascript 的保留關鍵字不可以用作變量、標籤或者函數名。有些保留關鍵字是作爲 Javascript 以後擴展使用。

JavaScript 對象、屬性和方法

您也應該避免使用 JavaScript 內置的對象、屬性和方法的名稱作爲 Javascript 的變量或函數名:

Array

Date

eval

function

hasOwnProperty

Infinity

isFinite

isNaN

isPrototypeOf

length

Math

NaN

name

Number

Object

prototype

String

toString

undefined

valueOf

 

 

Java 保留關鍵字

JavaScript 經常與 Java一起使用。您應該避免使用一些 Java對象和屬性作爲 JavaScript標識符:

getClass

java

JavaArray

javaClass

JavaObject

JavaPackage

 

Windows 保留關鍵字

JavaScript 可以在 HTML外部使用。它可在許多其他應用程序中作爲編程語言使用。

HTML 中,您必須(爲了可移植性,您也應該這麼做)避免使用HTML Windows 對象和屬性的名稱作爲Javascript 的變量及函數名:

alert

all

anchor

anchors

area

assign

blur

button

checkbox

clearInterval

clearTimeout

clientInformation

close

closed

confirm

constructor

crypto

decodeURI

decodeURIComponent

defaultStatus

document

element

elements

embed

embeds

encodeURI

encodeURIComponent

escape

event

fileUpload

focus

form

forms

frame

innerHeight

innerWidth

layer

layers

link

location

mimeTypes

navigate

navigator

frames

frameRate

hidden

history

image

images

offscreenBuffering

open

opener

option

outerHeight

outerWidth

packages

pageXOffset

pageYOffset

parent

parseFloat

parseInt

password

pkcs11

plugin

prompt

propertyIsEnum

radio

reset

screenX

screenY

scroll

secure

select

self

setInterval

setTimeout

status

submit

taint

text

textarea

top

unescape

untaint

window

HTML 事件句柄

除此之外,您還應該避免使用 HTML 事件句柄的名稱作爲 Javascript 的變量及函數名。

實例:

onblur

onclick

onerror

onfocus

onkeydown

onkeypress

onkeyup

onmouseover

onload

onmouseup

onmousedown

onsubmit

網址參考:

http://www.runoob.com/js/js-reserved.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章