JavaScript里的mixin
这似乎是一个模式,用于构造一个新的object,有一个函数可以来实现这个mixin,Object.assign()
。
这似乎是一个模式,用于构造一个新的object,有一个函数可以来实现这个mixin,Object.assign()
。
摘抄自Understanding ECMAScript 6
:
this
, super
, arguments
, and new.target
bindings - The value of this
, super
, arguments
, and new.target
inside of the function is by the closest containing nonarrow function. (super
is covered in Chapter 4.)new
- Arrow functions do not have a [[Construct]]
method and therefore cannot be used as constructors. Arrow functions throw an error when used with new
.new
on an arrow function, there's no need for a prototype. The prototype
property of an arrow function doesn't exist.this
- The value of this
inside of the function can't be changed. It remains the same throughout the entire lifecycle of the function.arguments
object - Since arrow functions have no arguments
binding, you must rely on named and rest parameters to access function arguments.There are a few reasons for these differences. First and foremost, this
binding is a common source of error in JavaScript. It's very easy to lose track of the this
value inside a function, which can result in unintended program behavior, and arrow functions eliminate this confusion. Second, by limiting arrow functions to simply executing code with a single this
value, JavaScript engines can more easily optimize these operations, unlike regular functions, which might be used as a constructor or otherwise modified.
The rest of the differences are also focused on reducing errors and ambiguities inside of arrow functions. By doing so, JavaScript engines are better able to optimize arrow function execution.
Note: Arrow functions also have a name
property that follows the same rule as other functions.
详细请看下面的代码:
<?php
$msg="Hello World!";
echo '$msg';//这个打印出来$msg,而不是Hello World!
echo $msg, "$msg";//不带引号,或者双引号,都能识别$msg是一个变量,唯独单引号不行
?>
基本意思是,如果你某个值foo
的验证规则加了一个confirmed
,那么你就必须发送另一个值foo_confirmation
,而且这俩的值必须相同。
文档原文:
confirmed
The field under validation must have a matching field of foo_confirmation. For example, if the field under validation is password, a matching password_confirmation field must be present in the input.
Template Literals
,也就是模板字面量
,非常强大,对于操作字符串,非常有用,至少解决了ES5
没有解决的3个问题:
有时候,需要使用一些命令使得更改后的各种配置文件生效,可以执行如下2个命令:
source .env //针对.env文件
php artisan config:cache
很多很多配置文件,如果一旦更改,记得清空cache,否则不生效。