Home  >  Article  >  Web Front-end  >  JavaScript声明变量名的语法规则_javascript技巧

JavaScript声明变量名的语法规则_javascript技巧

WBOY
WBOYOriginal
2016-05-16 15:50:521049browse

一、语法规则

  1.变量必须使用字母、下划线(_)或者美元符($)开始。

  2.然后可以使用任意多个英文字母、数字、下划线(_)或者美元符($)组成。

  3.不能使用JS关键词与保留字。

二、示例  

  var score;
  score="100";

三、注意

  1.JS区分大小写。如变量score与Score是不一样的,相当两个变量。

  2.变量虽然可以不声明,直接使用,但不规范,会涉及变量名提升等问题。

以上所述就是本文的全部内容了,希望大家能够喜欢。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn