Get the App
SLTechnology News&Howtos  ›  Development  › 

Is the javascript keyword var?

Shulou Source: shulou.com Published: 2022-06-03 17:27:33 11月13日 Update

Editor to share with you whether the javascript keyword is var, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Var is the keyword in javascript, but the js keyword is not only var, but also break, else, new, case, finally, return, void, catch, for, switch, while, continue, this, with, if and so on.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Javascript keyword

Keywords are a set of names (or commands) used within the JavaScript language specified by ECMA-262. These names have a specific purpose, and users cannot customize identifiers of the same name. The details are shown in the table.

ECMAScript keyword breakdeleteifthiswhilecasedointhrowwithcatchelseinstanceoftry

Continuefinallynewtypeof

Debugger (new to ECMAScript 5) forreturnvar

Defaultfunctionswitchvoid

As you can see, var is the keyword in javascript, but the keyword of js is not only var, but also break, delete, if, this, while, and so on.

Javascript reserved word

ECMA also describes another set of reserved words that cannot be used as identifiers. Although reserved words do not have any specific use in the language, they may be used as keywords in the future. The following are all reserved words defined by ECMA version 3:

Abstract 、 enum 、 int 、 short 、 boolean 、 export 、 interface 、 static 、 byte 、 extends 、 long 、 super 、 char 、 final 、 native 、 synchronized 、 class 、 float 、 package 、 throws 、 const 、 goto 、 private 、 transient 、 debugger 、 implements 、 protected 、 volatile 、 double 、 import 、 public .

Using keywords as identifiers in code is a "Identifier Expected" error in most browsers. The use of reserved words may not cause the same error, depending on the browser. In general, it is best not to use keywords and reserved words as identifiers to be compatible with future versions of ECMAScript.

The content of keywords is not immutable, with the improvement of the version of JavaScript, keywords will also change, such as ES2015 added let and const as keywords.

The above is all the content of the article "whether the javascript keyword is var". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Keywords keywords identifiers identifiers content articles names browsers versions usage language errors browsing immutable generally speaking not much code but commands most Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Microsoft Huawei vpn