Object一些小技巧
## 使用对象代替条件 if 判断
在某些条件下,我们需要根据变量的值来调用不同的函数或者赋值。一般我们遇到这种情况可能会写大量的 if 条件判断块,但是大量的 if 代码不利于代码阅读和理解,有些时候我们可以使用对象来解决此问题。
<!--more-->
像以下例子中,使用了大量的 if else 判断条件,使得代码变得难以理解。
```javascript
function func(type) {
if (type == 'a') {
return 1;
} else if (type == 'b') {
return 2;
more...ES6一些Javascript 解构小技巧
ES6 允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构。
下面为大家介绍一些常用的解构赋值操作。
## **1. 变量交换**
ES6 之前我们变量交换的方式可能如下:
```javascript
var a = 1;
var b = 2;
var temp;
temp = a;
a = b;
b = temp;
```
在上述例子中 `temp` 其实是一个临时变量用来存储 `a` 的值,最后我们把 `temp` 的值赋值给 `b`。
使用解构运算则非常简单:
```javascript
let a = 1;
more...Prism Supported languages
# [Prism Supported languages](https://prismjs.com/#supported-languages)
This is the list of all 276 languages currently supported by Prism, with their corresponding alias, to use in place of `xxxx` in the `language-xxxx` (or `lang-xxxx`) class:
|
more...

