import{_ as s}from"./plugin-vue_export-helper-DlAUqK2U.js";import{c as a,a as t,o as h}from"./app-zNUiodpH.js";const n={};function l(k,i){return h(),a("div",null,[...i[0]||(i[0]=[t(`

JavaScript基本语法

变量

声明变量

var a = 1;

JavaScript有如下基本的变量类型Number, String, Boolean, Undefined, Null

var a=1;		//Number
var b="hello";	//String\`
var c=true;		//Boolean
var d;			//Undefined\`
var e=null;		//Null

JavaScript 是一种动态类型语言,也就是说,变量的类型没有限制,变量可以随时更改类型。

var a=1;
a="hello";

流程控制

条件(if...else 结构)

if (m === 0) 
{  
	// ...
} 
else if (m === 1) { 
 // ...
} 
else if (m === 2) {  
// ...
} 
else {  // ... }

switch 结构

switch (fruit) {  
case "banana":
	{
		//...
	}
    break;  
case "apple": 
    break;  
default:
}

循环

while循环

while(condition) {
	//do something
}

do {
	//do something
}while(condition)

for循环

for (var i = 0; i < 3; i++) {  
	console.log(i); // 0 1 2 
}

和c++一样,continue和break在循环体中起到同样作用

`,19)])])}const r=s(n,[["render",l]]),d=JSON.parse('{"path":"/note/language/javascript/grammar.html","title":"JavaScript基本语法","lang":"zh-CN","frontmatter":{"description":"JavaScript基本语法 变量 声明变量 JavaScript有如下基本的变量类型Number, String, Boolean, Undefined, Null JavaScript 是一种动态类型语言,也就是说,变量的类型没有限制,变量可以随时更改类型。 流程控制 条件(if...else 结构) switch 结构 循环 while循环 fo...","head":[["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"JavaScript基本语法\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2025-02-22T14:42:02.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"JinChao\\",\\"url\\":\\"https://thecodeway.com\\"}]}"],["meta",{"property":"og:url","content":"https://thejinchao.github.io/note/language/javascript/grammar.html"}],["meta",{"property":"og:site_name","content":"我的博客和笔记"}],["meta",{"property":"og:title","content":"JavaScript基本语法"}],["meta",{"property":"og:description","content":"JavaScript基本语法 变量 声明变量 JavaScript有如下基本的变量类型Number, String, Boolean, Undefined, Null JavaScript 是一种动态类型语言,也就是说,变量的类型没有限制,变量可以随时更改类型。 流程控制 条件(if...else 结构) switch 结构 循环 while循环 fo..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}],["meta",{"property":"og:updated_time","content":"2025-02-22T14:42:02.000Z"}],["meta",{"property":"article:modified_time","content":"2025-02-22T14:42:02.000Z"}]]},"git":{"createdTime":1740235322000,"updatedTime":1740235322000,"contributors":[{"name":"thejinchao","username":"thejinchao","email":"thejinchao@gmail.com","commits":1,"url":"https://github.com/thejinchao"}]},"readingTime":{"minutes":0.68,"words":205},"filePathRelative":"note/language/javascript/grammar.md","autoDesc":true}');export{r as comp,d as data};