Update README.md

master
Matt Huntington 8 years ago committed by GitHub
parent 378ac3dec9
commit fe976b27c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -381,25 +381,22 @@ for(let element of array){
When creating a constructor and you wanted a default value, you previously had to write something like this: When creating a constructor and you wanted a default value, you previously had to write something like this:
```JavaScript ```JavaScript
function Beverage( type ){ var multBy2 = function(value){
this.type = type || "water"; var defaultValue = (value)?value:0;
return defaultValue * 2
} }
var breakfast = new Beverage();
var breakfast2 = new Beverage( 'beer' ); console.log(multBy2());
console.log ( breakfast );
console.log ( breakfast2 );
``` ```
Now you can do this in ES6 Now you can do this in ES6
```JavaScript ```JavaScript
function Beverage ( type = 'sparkling water' ){ var multBy2 = function(value = 0){
this.type = type; return value * 2
} }
var breakfast = new Beverage();
var breakfast2 = new Beverage( 'rocket fuel' ); console.log(multBy2());
console.log ( breakfast );
console.log ( breakfast2 );
``` ```
## Array.isArray() ## Array.isArray()

Loading…
Cancel
Save