This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void SubmitOrder(OrderData data) { | |
| var customer = GetCustomer(data.CustomerId); | |
| var sendEmail = delegate { /* send email */ }; | |
| // call the domain model for the rest of the regular order submit logic customer.BecamePreferred -= sendEmail; | |
| // to avoid leaking memory | |
| customer.BecamePreferred += sendEmail; | |
| } | |
| public class CustomerBecamePreferredHandler : Handles<CustomerBecamePreferred> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Food { | |
| static isHealthy() { | |
| return true | |
| } | |
| static isEdible() { // references it's own class | |
| return this.isHealthy() | |
| } | |
| } | |
| console.log(Food.isEdible()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // what is the order of the statements logged to the console? | |
| console.log('script start'); | |
| setTimeout(function() { | |
| console.log('setTimeout'); | |
| }, 0); | |
| Promise.resolve().then(function() { | |
| console.log('promise1'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.3.1/redux.js"></script> | |
| <script src="https://fb.me/react-with-addons-0.14.7.js"></script> | |
| <script src="https://fb.me/react-dom-0.14.7.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/react-redux/4.4.0/react-redux.js"></script> | |
| <link href='https://fonts.googleapis.com/css?family=Open+Sans:600,700' rel='stylesheet' type='text/css'> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sideEffects() { | |
| console.log("this will have a side effect because thats how the object prototype mechanism just works"); | |
| } | |
| var User = function({first_name, last_name, language, num_friends, num_reports, college, active}) { | |
| var obj = Object.create(User.prototype) | |
| obj.first_name = first_name | |
| obj.last_name = last_name | |
| obj.language = language |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function sideEffects() { | |
| console.log("this will have a side effect because thats how the object prototype mechanism just works"); | |
| } | |
| function Bar () { | |
| console.log(`hey no side effects, we're all good!`); | |
| } | |
| Bar.prototype = new sideEffects(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // lexical this and this properties | |
| function test() { | |
| setTimeout(() => { | |
| console.log(this.a) | |
| }, 1000); | |
| } | |
| let a = 2; | |
| test(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> |