笔记:
对象结构能够帮助我们更为简便的提取对象中的属性,对其重命名,以及赋予默认值。
({name,age} = Tom); 小括号包裹起来。
<script type="text/javascript">
const Tom = {
name:'Tom Jones',
age:25,
family:{
mother:'Norah Jones',
father:'Richard Jones',
brother:'Howard Jones'
},
}
let name ='';
({name,age} = Tom);
console.log(name);
console.log(age);
</script>
嵌套,重命名
<script type="text/javascript">
const Tom = {
name:'Tom Jones',
age:25,
family:{
mother:'Norah Jones',
father:'Richard Jones',
brother:'Howard Jones'
},
}
const father = 'Dad';
const{father:f,mother:m,brother:b} =Tom.family;
console.log(f);
console.log(m);
console.log(b);
</script>
未定义的属性初始值为undefined的时候才会使用默认值
<script type="text/javascript">
const Tom = {
name:'Tom Jones',
age:25,
family:{
mother:'Norah Jones',
father:'Richard Jones',
brother:'Howard Jones',
sister:undefined
},
}
const father = 'Dad';
const{father:f,mother:m,brother:b,sister='have no sister'} =Tom.family;
console.log(sister);
</script>
一个个属性值注释掉看看初始值
<div class="container"></div>
<script type="text/javascript">
function appendChildDiv(options ={}){
const {parent = 'body',width = '100px',height = '80px',
backgroundColor = 'pink'} =options;
const div = document.createElement('div');
div.style.width = width;
div.style.height = height;
div.style.backgroundColor = backgroundColor;
document.querySelector(parent).appendChild(div);
}
appendChildDiv({
parent:'.container',
width:'200px',
// height:'150px',
// backgroundColor:'yellow'
})
</script>
笔记:
逗号分隔属性名
<script type="text/javascript">
const numbers = ['one','tow','three','four'];
const [one,,three] = numbers;
console.log(one,three);
</script>
…others 剩余元素组成新数组,…others只能放在数组最后
<script type="text/javascript">
const numbers = ['one','tow','three','four'];
const [one,...others] = numbers;
console.log(one,others);
</script>
数组中定义默认参数
<script type="text/javascript">
const numbers = ['one','tow','three','four'];
const [one,two,three,four,five='PHP'] = numbers;
console.log(one,two,three,four,five);
</script>
交换变量值
<script type="text/javascript">
let a = 10;
let b = 15;
[a,b] =[b,a];
console.log(a,b)
</script>
笔记:
最初的for循环,比较繁琐
<script type="text/javascript">
const fruits = ['Apple','Banana','Orange','Mango'];
for(let i=0;i<fruits.length;i++){
console.log(fruits[i]);
}
</script>
forEach循环,不能终止或者跳过
<script type="text/javascript">
const fruits = ['Apple','Banana','Orange','Mango'];
fruits.forEach(fruit =>{
// if(fruit ==='Orange'){
// break;
// }
console.log(fruit);
})
</script>
For in 遍历的是可枚举属性
<script type="text/javascript">
Array.prototype.first = function(){
return this[0];
}
const fruits = ['Apple','Banana','Orange','Mango'];
fruits.describe = 'My favorite fruits';
for(let index in fruits){
console.log(fruits[index]);
}
</script>
<script type="text/javascript">
Array.prototype.first = function(){
return this[0];
}
const fruits = ['Apple','Banana','Orange','Mango'];
fruits.describe = 'My favorite fruits';
for(let fruit of fruits){
if(fruit ==='Orange'){
continue;
}
console.log(fruit);
}
</script>
笔记:
For of循环可以用于数组、字符串、map、NodeList等,目前还不支持对象。
.entries() 取到索引和值
console.log(fruit[1]); 当前元素的值
<script type="text/javascript">
const fruits = ['Apple','Banana','Orange','Mango'];
for(let fruit of fruits.entries()){
console.log(fruit);
}
</script>
用结构的语法[index,fruit]
<script type="text/javascript">
const fruits = ['Apple','Banana','Orange','Mango'];
for(let [index,fruit] of fruits.entries()){
console.log(`${fruit} ranks ${index +1} in my favorite fruits`);
}
</script>
用于数组,求和
<script type="text/javascript">
function sum(){
let total =0;
for(let num of arguments){
total= total +num;
}
console.log(total);
return total;
}
sum(10,20,300,434,12,33);
</script>
用于字符串循环
<script type="text/javascript">
let name ='Veg.kim';
for(let char of name){
console.log(char);
}
</script>
用于li标签循环,click切换样式
<head>
<title>Var-Let-Const</title>
<style type="text/css">
.highlight{
padding:2px 5px;
background: #00adb5;
color:white;
}
</style>
</head>
<body>
<ul>
<li>Go to Store</li>
<li>Watch TV</li>
<li>Go shopping</li>
</ul>
<script type="text/javascript">
const lis = document.querySelectorAll('li');
for(let li of lis){
li.addEventListener('click',function(){
this.classList.toggle('highlight');
})
}
</script>
</body>
这个做ppt的不错https://ppt.baomitu.com
从别的网站上复制带图片的内容到UEditor里,粘贴的同时图片存储到自己的服务器上怎么做啊?
laravel项目默认在vendor/bin/phpunit
全局安装
➜ wget https://phar.phpunit.de/phpunit.phar
➜ chmod +x phpunit.phar
➜ sudo mv phpunit.phar /usr/local/bin/phpunit
➜ phpunit --version
PHPUnit 6.3.0 by Sebastian Bergmann and contributors.
Keymap搜索run context快捷键设置成control+shift+R
笔记:
Command + shift + a 输入file template
添加Eloquent Model
#if (${NAMESPACE})
namespace ${NAMESPACE};
#end
use Illuminate\Database\Eloquent\Model;
class ${NAME} extends Model {
protected \$fillable = [];
}
command+shift+a 搜索配置关键词
breadcrumbs \\编辑区样式
code folding \\编辑区折叠线
show right margin \\编辑区右侧边线
typo \\编辑区内容部分波浪线
command+P 快速查找文件快捷键
control + command +M 查看类中有哪些方法的快捷键
command+E 查看最近打开的文件
option +command +O 设置symbols快捷键,查找任意方法
chmod -R 777 /usr/local