Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Is the javascript keyword var?

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report