<commit_before>---
title: JS基础笔记(DOM)
layout: post
---

# 变量Var
## Assign初始值的重要性 
```
var a;  
var b;  
var c;
a = a + 1;  
b = b + 5;  
c = c + " String!";
```
> result a = NaN, b=NaN, c = "undefined String!"

# 字符串数组
    var myStr = "Bob";
    myStr[0] = "J";
* methods  
    .charAt(index) is another use  
    .indexOf  
    .split(delimiter,limit)  
    .substring( 起点 ， 终点 )  
	.substr( 起点 ，长度 )  

cannot change the value of myStr to "Job", 
because the contents of myStr cannot be altered. 
Note that this does not mean that myStr cannot be changed, 
just that the individual characters of a string literal cannot be changed. 


# Create global variables
* outside of function - var globalvar
* inside function - declare without var 

# break
break是退出循环，不是跳出if语句<commit_msg>Update 2016-05-16-JS-note.md<commit_after>---
title: JS基础笔记(DOM)
layout: post
---

# 变量Var
## Assign初始值的重要性 
```
var a;  
var b;  
var c;
a = a + 1;  
b = b + 5;  
c = c + " String!";
```
> result a = NaN, b=NaN, c = "undefined String!"

# 字符串数组
    var myStr = "Bob";
    myStr[0] = "J";
> cannot change the value of myStr to "Job", 
because the contents of myStr cannot be altered. 
Note that this does not mean that myStr cannot be changed, 
just that the individual characters of a string literal cannot be changed. 

* methods  
    .charAt(index) is another use  
    .indexOf  
    .split(delimiter,limit)  
    .substring( 起点 ， 终点 )  
	.substr( 起点 ，长度 )  


# Create global variables
* outside of function - var globalvar
* inside function - declare without var 

# break
break是退出循环，不是跳出if语句
{'fraction_non_alphanumeric': 0.11385199240986717, 'fraction_numerical': 0.008855154965211892, 'mean_word_length': 2.8585365853658535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2823804', 'n_tokens_mistral': 622, 'n_tokens_neox': 622, 'n_words': 212}