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
| var list1 = [2, 4, 5, 6]; | |
| var list2 = [3, 5, 8, 9]; | |
| merged_list = merge_sorted_list(list1, list2); | |
| alert(merged_list); | |
| function merge_sorted_list(list1, list2) { | |
| merged_list = list1.concat(list2); | |
| return merged_list.sort(numsort); | |
| } |
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
| console.log(/p.*g/.test('programming')); // true | |
| console.log(/p.*g/.test('pickles')); // false | |
| var re = /quick\s(brown).+?(jumps)/ig; | |
| var result = re.exec( | |
| 'The Quick Brown Fox Jumps Over The Lazy Dog' | |
| ); | |
| console.log(result); | |
| // ["Quick Brown Fox Jumps", "Brown", "Jumps"] |
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
| li { | |
| display: none; | |
| } | |
| /* select items 1 through 3 and show them */ | |
| li:nth-child(-n+3) { | |
| display: block; | |
| } |
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
| // var last = arr.reverse()[0]; | |
| Array.prototype.last = function () { return this.length > 0 ? this[this.length -1] : undefined }; |
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
| @import "core.css"; | |
| @import "theme.css"; | |
| @import "user-theme.css"; | |
| @import "small-breakpoint.css" (max-width: 40em); | |
| @import "landscape.css" screen and (orientation: landscape); | |
| @import "print.css" print; |
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
| var myString = 'EXAMPLEstring'; | |
| var myNewString = myString.replace(/[A-Z]/g, '0'); | |
| console.log(myNewString); | |
| function replaceFunc (a, b, c) { | |
| console.log(a, b, c); | |
| return a.toLowerCase(); | |
| } | |
| var myOtherString = myString.replace(/[A-Z]/g, replaceFunc); |
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
| <div class="container"> | |
| <form class="form"> | |
| <div class="form-group"> | |
| <label class="sr-only" for="emailAddress">Email Address</label> | |
| <input class="form-control input-lg" type="email" placeholder="example@email.com" id="emailAddress" required> | |
| <button type="submit" class="btn btn-default input-lg">Subscribe</button> | |
| </form> | |
| </div> |
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
| const SourceElement = React.createClass({ | |
| componentDidMount: f() { | |
| this.props.view.addSource(this.props.source); | |
| }, | |
| componentWillUnumount: f() { | |
| this.props.view.removeSource(this.props.source); | |
| }, | |
| componentWillReceiveProps: f(nextProps) { |
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
| var myImg = document.querySelector('img'), | |
| op = document.querySelector('output'); | |
| op.innerHTML = "Computed width: " + | |
| getComputedStyle(myImg).getPropertyValue('width') + | |
| '<br>' + 'img.width: ' + | |
| myImg.width + | |
| '<br>' + 'getAttribute(width): ' + | |
| myImg.getAttribute('width') + | |
| '<br>' + 'img.naturalWidth: ' + |
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
| // returns first element selected - $('input[name="food"]') | |
| var $ = document.querySelector.bind(document); | |
| // return array of selected elements - $$('img.dog') | |
| var $$ = document.querySelectorAll.bind(document); | |
| // Credit: https://twitter.com/wesbos/status/608341616173182977 |