This file contains 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
// works in a similar way to LINQ with some minor differences. | |
using System; | |
using System.Collections; | |
using System.Runtime.CompilerServices; | |
namespace MiniLinqApi | |
{ | |
[IgnoreNamespace] | |
internal static class MiniLinq |
This file contains 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
Choose a ticket class: <select id="tickets"></select> | |
<p id="ticketOutput"></p> | |
<script id="ticketTemplate" type="text/x-jquery-tmpl"> | |
{{if chosenTicket}} | |
You have chosen <b>${ chosenTicket().name }</b> | |
($${ chosenTicket().price }) | |
<button data-bind="click: resetTicket">Clear</button> | |
{{/if}} |
This file contains 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
const user = { id: 100, name: 'Howard Moon'} | |
const userWithPass = { ...user, password: 'Password!' } | |
user //=> { id: 100, name: 'Howard Moon' } | |
userWithPass //=> { id: 100, name: 'Howard Moon', password: 'Password!' } |
This file contains 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
const part1 = { id: 100, name: 'Howard Moon' } | |
const part2 = { id: 100, password: 'Password!' } | |
const user1 = { ...part1, ...part2 } | |
//=> { id: 100, name: 'Howard Moon', password: 'Password!' } |
This file contains 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
const noPassword = ({ password, ...rest }) => rest | |
const user = { | |
id: 100, | |
name: 'Howard Moon', | |
password: 'Password!' | |
} | |
noPassword(user) //=> { id: 100, name: 'Howard moon' } |
This file contains 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
const partial = { id: 100, name: 'Howard Moon' } | |
const user = { ...partial, id: 100, password: 'Password!' } | |
user //=> { id: 100, name: 'Howard Moon', password: 'Password!' } |
This file contains 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
const user1 = { | |
id: 100, | |
name: 'Howard Moon', | |
password: 'Password!' | |
} | |
const removeProperty = prop => ({ [prop]: _, ...rest }) => rest | |
// ---- ------ | |
// \ / | |
// dynamic destructuring |
This file contains 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
const user3 = { | |
password: 'Password!', | |
name: 'Naboo', | |
id: 300 | |
} | |
const organize = object => ({ id: undefined, ...object }) | |
// ------------- | |
// / | |
// move id to the first property |
This file contains 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
const user3 = { | |
password: 'Password!', | |
name: 'Naboo', | |
id: 300 | |
} | |
const organize = ({ password, ...object }) => | |
({ ...object, password }) | |
// -------- | |
// / |
This file contains 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
const user2 = { | |
id: 200, | |
name: 'Vince Noir' | |
} | |
const user4 = { | |
id: 400, | |
name: 'Bollo', | |
quotes: ["I've got a bad feeling about this..."] | |
} |
OlderNewer